APIs with Databases (ORM)
-
Overview

-
Lets create a simple store service. This service is responsible for
- Creating stores
- updating stores
- retrieving stores
- Delete stores
-
Each store will have
- a unique id
- name
- city
- area
- address
-
Design our APIs:
- Create store:
- POST
- Update store:
- PUT
- PATCH
- Retrieve:
- all stores
- stores by id
- stores by city
- Delete:
- Soft Delete
- Hard Delete
- Create store:
LEts create the project
- Create a folder called as
store_service
mkdir store_service
cd store_service
uv init .
- Now add the following dependencies
uv add fastapi SQLAlchemy
uv add python-dotenv
-
Refer Here for the changes for basic folder structure and database
-
Refer Here for two api calls implemented
-
Exercise:
- Create a similar course-service
- In the course-service try using postgres or mysql db
