Skip to content

This project demonstrates how to build a FastAPI app connected to a MySQL database using SQLAlchemy and `mysqlclient`. It uses an existing table (`customers`) from a typical database schema.

Notifications You must be signed in to change notification settings

pravin-python/python-fast-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ FastAPI + MySQL (Existing DB) - API

This project demonstrates how to build a FastAPI app connected to a MySQL database using SQLAlchemy and mysqlclient.
It uses an existing table (customers) from a typical Northwind database schema without recreating or deleting the table.


πŸ“ Project Structure

fastapi_project/ β”œβ”€β”€ app/ β”‚ β”œβ”€β”€ main.py # FastAPI app entry point β”‚ β”œβ”€β”€ database.py # SQLAlchemy DB connection β”‚ β”œβ”€β”€ models/ β”‚ β”‚ └── customers.py # SQLAlchemy model (mapped to existing table) β”‚ β”œβ”€β”€ schemas/ β”‚ β”‚ └── customers.py # Pydantic schema for API response β”‚ β”œβ”€β”€ crud/ β”‚ β”‚ └── customers.py # Database queries β”‚ β”œβ”€β”€ routers/ β”‚ β”‚ └── customers.py # API endpoint β”‚ └── init.py β”œβ”€β”€ requirements.txt └── README.md


βš™οΈ Setup Instructions

1. Clone the repository

git clone https://github.com/your-username/fastapi-mysql-northwind.git
cd fastapi-mysql-northwind

pip install -r requirements.txt


sudo apt install libmysqlclient-dev python3-dev

uvicorn app.main:app --reload

About

This project demonstrates how to build a FastAPI app connected to a MySQL database using SQLAlchemy and `mysqlclient`. It uses an existing table (`customers`) from a typical database schema.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages