This is a simple CRUD (Create, Read, Update, Delete) application built using FastAPI with integration to Supabase, a powerful and flexible open-source alternative to Firebase for data storage.
This application provides basic CRUD operations for managing data stored in a Supabase database. It includes endpoints to:
- Fetch all data from a table
- Fetch data by ID
- Insert new data
- Update existing data
- Delete data by ID
- Python 3.7+
- FastAPI
- Pydantic
- Supabase Python client
- Uvicorn (for running the FastAPI application)
pip install fastapi
pip install supabase
Before running the application, you need to set up your Supabase credentials. Update the following variables in main.py:
export SUPABASE_URL="YOUR_SUPABASE_URL"
export SUPABASE_KEY="YOUR_SUPABASE_KEY"
Run the FastAPI application:
uvicorn main:app --host 127.0.0.1 --port 8000
- GET /: Returns a sample response.
- GET /fetch: Fetches all data from the specified table.
- GET /fetch/{id}: Fetches data by ID.
- POST /insert: Inserts new data into the table.
- PUT /update/{id}: Updates existing data by ID.
- DELETE /delete/{id}: Deletes data by ID.
The application uses the following data model:
class Base(BaseModel):
title: str
description: str