Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vasll/fastapi-mysql-replit-template
A replit template for FastAPI + MySQL
https://github.com/vasll/fastapi-mysql-replit-template
fastapi mariadb mysql nix pydantic python python3 repl replit shell shell-script sqlalchemy
Last synced: 5 days ago
JSON representation
A replit template for FastAPI + MySQL
- Host: GitHub
- URL: https://github.com/vasll/fastapi-mysql-replit-template
- Owner: vasll
- Created: 2023-03-28T19:15:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T14:21:50.000Z (almost 2 years ago)
- Last Synced: 2024-11-18T20:03:25.248Z (2 months ago)
- Topics: fastapi, mariadb, mysql, nix, pydantic, python, python3, repl, replit, shell, shell-script, sqlalchemy
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI + MySQL replit template
This template allows you to run a FastAPI server and a MySQL database on Replit.
## Getting started
1. Fork this template. You can fork it on replit [from here](https://replit.com/@vasll/FastAPI-MySQL)
2. Inside the [secrets tab](https://docs.replit.com/programming-ide/workspace-features/storing-sensitive-information-environment-variables) in the replit tools add the following:
- `db_user` Name of the user that will have full access to the db
- `db_pass` Password for the user
- `db_name` Name of the database to be created
3. Click the `Run` button and the MySQL database, credentials and [Python venv](https://docs.python.org/3/library/venv.html) will be created for you using the given secrets## Files and folders
### `app/`
Contains example FastAPI code to connect to a database using [SQLAlchemy](https://fastapi.tiangolo.com/tutorial/sql-databases/).
- `main.py`: sets up a FastAPI instance and stars the uvicorn server
- `database.py`: establishes a db connection and contains the [db dependency](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/)
- `schemas.py`: contains db schemas (tables)
- `models.py`: contains models based on db schemas, used for data validation### `startup.sh`
Creates a venv in `.venv/` and installs a MySQL server instance into `sql_data/`## Credits
The MySQL database creation .sh script was forked from this repl: [@dprevedello/PHP-MySQL](https://replit.com/@dprevedello/PHP-MySQL)