'Python: Latest data isn't pulled fromsqlite3 database when using os with jupyter nbconvert

I have a weird issue with my code that I haven't been able to solve. I have a sqlite3 database that I refresh every morning with an automated task. I know the database is refreshed, because when I make an extract it's pulling in the latest data. However, I have a piece of code which refreshes my jupyter notebooks which contains code pulling data from that sqlite3 database and publishes them to html using os and jupyter nbconvert. However, when I run that code, the jupyter notebooks does not pull the latest data from sqlite3. I have to run the code several times and it randomly works at some point. It seems like this might be some kind of kernel issue, but it has me really confused as I'm not too knowledgeable about kernel management etc. Any idea how to fix this?

import os
import DataDownloader

#Pulls the data and initalises the sql database
DataDownloader.dbinit()

#Runs and converts jupyter notebooks to html
os.system(r'jupyter nbconvert --execute "G:\Notebooks\Notebook1.ipynb" --no-input --to html --output "G:\Notebooks\Notebook1.html"')
os.system(r'jupyter nbconvert --execute "G:\Notebooks\Notebook2.ipynb" --no-input --to html --output "G:\Notebooks\Notebook2.html"')
os.system(r'jupyter nbconvert --execute "G:\Notebooks\Notebook3.ipynb" --no-input --to html --output "G:\Notebooks\Notebook3.html"')



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source