I'm building a web application which utilizes SQLAlchemy to store and retrieve data. My goal is to update the SQLite database on a scheduled daily basis in the background as the app is constantly running. My current approach works as the following:
- The SQLite database is first initialized and built from the script:
initializedb.pyby reading through a series of text files and adding the proper information as rows in a table to the database - The Pyramid app is then run and is accessible via
localhost:6543 - The user is then able to access a list read from the SQLite database, rendered using a Jinja2 template
My app will be constantly running 24/7 so that the user can access this list whenever. Because the text files which I initialize the database from are constantly updating, I want to be able to update the database as well everyday. My main question is this:
How would I automatically update the database on a daily basis using SQLAlchemy and Pyramid?
Should the code to update the database periodically be done on a script running separately from the app, or should it be done in the Pyramid code itself, such as in views.py?