This template allows you to run a FastAPI server and a MySQL database on Replit.
- Fork this template. You can fork it on replit from here
- Inside the secrets tab in the replit tools add the following:
db_user
Name of the user that will have full access to the dbdb_pass
Password for the userdb_name
Name of the database to be created
- Click the
Run
button and the MySQL database, credentials and Python venv will be created for you using the given secrets
Contains example FastAPI code to connect to a database using SQLAlchemy.
main.py
: sets up a FastAPI instance and stars the uvicorn serverdatabase.py
: establishes a db connection and contains the db dependencyschemas.py
: contains db schemas (tables)models.py
: contains models based on db schemas, used for data validation
Creates a venv in .venv/
and installs a MySQL server instance into sql_data/
The MySQL database creation .sh script was forked from this repl: @dprevedello/PHP-MySQL