Python Classroom notes 06/Jun/2026

APIs with Databases (ORM)

  • Overview
    Preview

  • 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

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

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading