https://github.com/karan071/starter-template-prisma-py
This repository provides a comprehensive starter template for building Python web applications using FastAPI, Prisma Client Python, and PostgreSQL as the database. It is designed for developers looking to set up a robust and scalable backend with modern tools and frameworks.
https://github.com/karan071/starter-template-prisma-py
docker fastapi postgresql-database prisma-orm python
Last synced: about 2 months ago
JSON representation
This repository provides a comprehensive starter template for building Python web applications using FastAPI, Prisma Client Python, and PostgreSQL as the database. It is designed for developers looking to set up a robust and scalable backend with modern tools and frameworks.
- Host: GitHub
- URL: https://github.com/karan071/starter-template-prisma-py
- Owner: Karan071
- Created: 2024-11-23T11:50:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-23T12:14:00.000Z (over 1 year ago)
- Last Synced: 2025-01-23T03:33:31.312Z (over 1 year ago)
- Topics: docker, fastapi, postgresql-database, prisma-orm, python
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI + Prisma Client Python + PostgreSQL Starter Template
This repository is a starter template for building Python web applications using **FastAPI**, **Prisma Client Python**, and **PostgreSQL**. It includes a pre-configured project structure, database connection setup, and tools for managing migrations and queries.
---
## Table of Contents
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Setup Instructions](#setup-instructions)
- [Project Structure](#project-structure)
- [Usage](#usage)
- [License](#license)
---
## Features
- 🚀 **FastAPI**: High-performance Python framework for APIs.
- 🗄️ **Prisma Client Python**: Modern ORM with type-safe database queries.
- 🐘 **PostgreSQL**: Using Docker image.
- 🔧 **Environment Variables**: Simplified configuration with `.env`.
- 📜 **Migrations**: Prisma schema-based database migrations.
---
## Prerequisites
Ensure you have the following installed:
- **Python** (3.8 or higher)
- **PostgreSQL** (Latest version)
- **Node.js** (v16+ for Prisma CLI)
---
## Setup Instructions
### Step 1: Clone the Repository
```bash
git clone https://github.com/Karan071/Starter-template-Prisma-Py.git
cd your-repo
```
### Step 2: Set Up the Python Environment
Create a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # mac users
.\venv\Scripts\activate # windows
```
### Step 3: Install the Python dependencies:
```bash
pip install -r requirements.txt
```
### Step 4: Run the docker.yaml file
```bash
docker compose -f "docker-compose.yaml" up -d --build
```
### Step 5: Generate the Prisma Client
```Bash
npx prisma generate
```
### Step 6 : Apply Database Migrations
```Bash
npx prisma migrate dev --name init
```
### Step 7: Run the FastAPI Application
Start the FastAPI development server:
```Bash
uvicorn app.main:app --reload
```
Querying the Database
Use the Prisma Python client for database queries. Example:
python
```Bash
from prisma import Prisma
db = Prisma()
db.connect()
# Create a new post
post = db.post.create(
data={
"title": "Hello World",
"content": "This is a test post.",
}
)
print(post)
db.disconnect()
```