Skip to content

RahulMule/fastapi-sqlmodel-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI-SQLModel-PostgreSQL Game API

A simple REST API to manage games using FastAPI, SQLModel, and PostgreSQL (hosted on Azure).

Features

  • CRUD Operations: Create, Read, Update, and Delete games.
  • SQLModel for database interactions.
  • FastAPI for building RESTful APIs.
  • PostgreSQL hosted on Azure.

Requirements

  • Python 3.8+
  • PostgreSQL (Azure or Local)
  • FastAPI & SQLModel

Setup Instructions

1️⃣ Clone Repository

git clone https://github.com/RahulMule/fastapi-sqlmodel-demo
cd fastapi-sqlmodel-demo

2️⃣ Create a Virtual Environment

python -m venv .venv
source .venv/bin/activate  # On Windows use: .venv\Scripts\activate

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Configure Database

Update the database/db.py file with your PostgreSQL connection string:

DATABASE_URL = "postgresql://username:password@hostname:port/database_name"

5️⃣ Run the Application

uvicorn app.main:app --reload

6️⃣ Access the API Docs

Once running, you can explore the API with Swagger UI:


API Endpoints

📌 Create a Game

POST /games/

Request Body:

{
  "title": "Elden Ring",
  "genre": "RPG",
  "platform": "PC",
  "release_year": 2022
}

📌 Get All Games

GET /games/

📌 Get a Single Game

GET /games/{game_id}

📌 Update a Game

PUT /games/{game_id}

Request Body:

{
  "title": "Elden Ring: Shadow Edition",
  "genre": "RPG",
  "platform": "PC",
  "release_year": 2023
}

📌 Delete a Game

DELETE /games/{game_id}

🔥 Technologies Used

  • FastAPI - High-performance web framework
  • SQLModel - ORM for structured data
  • PostgreSQL - Database hosted on Azure
  • Uvicorn - ASGI server

👨‍💻 Contributing

  1. Fork the repo & create a new branch.
  2. Make changes and commit them.
  3. Open a Pull Request.

📜 License

This project is licensed under the MIT License.


🚀 Happy Coding! 🎮

About

A simple REST API to manage games using **FastAPI**, **SQLModel**, and **PostgreSQL** (hosted on Azure).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages