This is a simple FastAPI project that interacts with a MySQL database.
This project demonstrates how to create a RESTful API using FastAPI to perform basic CRUD operations on a MySQL database.
- Python 3.x
- FastAPI
- uvicorn
- mysql-connector-python
-
Clone the repository:
git clone https://github.com/Marwan-Gama/saints-app.git
-
Install the dependencies:
pip install fastapi uvicorn mysql-connector-python
- Configure your MySQL connection in config.py.
- Run the FastAPI server:
uvicorn main:app --reload
- Access the API documentation at http://localhost:8000/docs.
- /: Homepage.
- /data: Fetch all customer data.
- /saints: Fetch all saints.
- /who?name={name}: Fetch customer by name.
- /saints (POST): Add a new saint.
- /short-desc: Fetch a short description of customers.
- /admin/saint/age/{min_age}/{max_age}: Fetch saints within a specific age range.
- /admin/notsaint/age/{min_age}/{max_age}: Fetch non-saints within a specific age range.
- /admin/name/{search_name}: Fetch saints by name.
- /admin/average: Fetch average ages of saints and non-saints.