This application structure and set-up follows the steps outlined in Using Flask-SQLAlchemy with Flask Applications on Posit Connect:
- Creating a minimal application based on the Flask-SQLAlchemy quickstart guide
- Define the database model to use
- Initialize a SQLite database
- Commit data to the database
- Deploy the application to Posit Connect with rsconnect-python
And, optionally:
- Switch to a PostgreSQL database server
- Add
pyscopg2dependency to the Python environment - Add the database server connection string as an environment variable in Posit Connect
- Redeploy the application
Run the following to create the sqlite database used by the application:
python seed_db.py
rsconnect deploy api . -n <SERVER-NICKNAME>