A simple CRUD API built using FastAPI, PostgreSQL, and SQLAlchemy. This project demonstrates how to build a backend service with database integration using modern Python tools.
- Create, Read, Update, Delete (CRUD) operations
- FastAPI framework for high performance APIs
- PostgreSQL database integration
- SQLAlchemy ORM
- Pydantic data validation
- Auto-generated API documentation (Swagger UI)
- Python 3.10+
- FastAPI
- PostgreSQL
- SQLAlchemy
- Uvicorn
- Pydantic
- python-dotenv
FASTAPI_POSTGRES/
│── main.py
│── database.py
│── models.py
│── schemas.py
│── crud.py
│── requirements.txt
│── .env
│── .gitignore
│── venv/
git clone https://github.com/pranjaykumar926/fastapi-postgres-crud.git
cd fastapi-postgres-crudpython -m venv venvActivate it:
Windows:
venv\Scripts\activatepip install -r requirements.txtCreate a .env file:
DATABASE_URL=postgresql://postgres:admin123@localhost:5432/bookstoreuvicorn main:app --reloadAfter running the server, open:
http://127.0.0.1:8000/docs
You will see interactive Swagger UI.
POST /items/
GET /items/
GET /items/{id}
PUT /items/{id}
DELETE /items/{id}
- Database name:
bookstore - Default user:
postgres - Port:
5432
- Do NOT commit
.envorvenv/to GitHub - Keep credentials secure
- JWT Authentication
- Pagination
- Docker support
- Alembic migrations
- Role-based access control
Pranjay Kumar GitHub: https://github.com/pranjaykumar926