Skip to main content

Supabase Pydantic Schemas

PyPI Version Conda Version Pydantic v2 GitHub License codecov PePy Downloads PyPI - Downloads

A project for generating Pydantic and SQLAlchemy models from Supabase and MySQL databases. This tool bridges the gap between your database schema and your Python code, providing type-safe models for FastAPI and other frameworks.

Currently, this is ideal for integrating FastAPI with supabase-py as a primary use-case. This project is inspired by the TS type generating capabilities of supabase cli. Its aim is to provide a similar experience for Python developers.

Project status (August 2026): maintenance mode. supabase-pydantic continues to receive bug fixes and dependency updates; nothing is being removed, and no end-of-life date has been set. New feature work has moved to castiron, its successor, which carries this project's schema-fidelity engine onto a source-agnostic architecture.

castiron is 0.1.0 and pre-alpha: today it reads the OpenAPI document a Supabase/PostgREST project publishes — no database connection, no driver — and emits Pydantic v2 models. It does not yet connect to a live database, emit SQLAlchemy models, read MySQL, or generate seed data, all of which supabase-pydantic does today. If you rely on those, stay here for now.

Install with pip install cast-iron (the distribution is hyphenated; the command and the import package are castiron). Docs · Repo · What this means for supabase-pydantic users

📣 NEW (Aug 2025): MySQL support! Generate models directly from MySQL databases with the --db-type mysql flag. See the docs

📣 NEW (Aug 2025): SQLAlchemy models with Insert and Update variants for better type safety. Learn more

Installation

# Install with pip
$ pip install supabase-pydantic

# Or with conda
$ conda install -c conda-forge supabase-pydantic

Configuration

Create a .env file with your database connection details:

DB_NAME=<your_db_name>
DB_USER=<your_db_user>
DB_PASS=<your_db_password>
DB_HOST=<your_db_host>
DB_PORT=<your_db_port>

Usage

Generate Pydantic Models

Example with full command output (using a local connection):

$ sb-pydantic gen --type pydantic --framework fastapi --local

2025-08-18 15:47:42 - INFO - supabase_pydantic.db.connection:check_connection:72 - PostGres connection is open.
2025-08-18 15:47:42 - INFO - supabase_pydantic.db.connection:construct_tables:136 - Processing schema: public
2025-08-18 15:47:42 - INFO - supabase_pydantic.db.connection:__exit__:105 - PostGres connection is closed.
2025-08-18 15:47:42 - INFO - supabase_pydantic.cli.commands.gen:gen:239 - Generating Pydantic models...
2025-08-18 15:47:42 - INFO - supabase_pydantic.cli.commands.gen:gen:251 - Pydantic models generated successfully for schema 'public': /path/to/your/project/entities/fastapi/schema_public_latest.py
2025-08-18 15:47:42 - INFO - supabase_pydantic.cli.commands.gen:gen:258 - File formatted successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py

Common Commands

Using a database URL:

$ sb-pydantic gen --type pydantic --framework fastapi --db-url postgresql://postgres:postgres@127.0.0.1:54322/postgres

Generating models for specific schemas:

$ sb-pydantic gen --type pydantic --framework fastapi --local --schema extensions --schema auth

Generate SQLAlchemy models:

$ sb-pydantic gen --type sqlalchemy --local

Using MySQL:

$ sb-pydantic gen --type pydantic --framework fastapi --db-type mysql --db-url mysql://user:pass@localhost:3306/dbname

Makefile Integration

# Makefile examples for both Pydantic and SQLAlchemy generation

gen-pydantic:
    @echo "Generating FastAPI Pydantic models..."
    @sb-pydantic gen --type pydantic --framework fastapi --dir ./entities/fastapi --local

gen-sqlalchemy:
    @echo "Generating SQLAlchemy ORM models..."
    @sb-pydantic gen --type sqlalchemy --dir ./entities/sqlalchemy --local

# Generate all model types at once
gen-all: gen-pydantic gen-sqlalchemy
    @echo "All models generated successfully."

For full documentation, visit our docs site.

Metadata

Release files for supabase-pydantic 0.26.29

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for supabase-pydantic 0.26.29
File Size Uploaded Provenance Actions
supabase_pydantic-0.26.29.tar.gz 84.0 kB With provenance Details for supabase_pydantic-0.26.29.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for supabase-pydantic 0.26.29
File Interpreter ABI Platform Actions
supabase_pydantic-0.26.29-py3-none-any.whl Python 3 none any Details for supabase_pydantic-0.26.29-py3-none-any.whl

Total release size: 196.5 kB

Release files / supabase_pydantic-0.26.29.tar.gz

Download URL supabase_pydantic-0.26.29.tar.gz
Size 84.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c8534a16661eead12bd4ea942e85fc726c116d7879b7b4ab6be170c6d3f3e786
BLAKE2b-256 checksum
How to use checksums
0383d9ed572ddba8bb939d030d0cc3ead4e464d47c09e275ce619a67d8fb49e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / supabase_pydantic-0.26.29-py3-none-any.whl

Download URL supabase_pydantic-0.26.29-py3-none-any.whl
Size 112.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66d0ff7cd2160bee7ac6b8d3ee794516893c29a740217f2e571d8fe19c52f0fd
BLAKE2b-256 checksum
How to use checksums
9760d03ff099ba9a444fdb2ce12676a062e2ca28a43973967e98c1021bcc1cf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for supabase-pydantic 0.26.29

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for supabase_pydantic-0.26.29.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.26.29 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page