{"id":14968969,"url":"https://github.com/kmbhm1/supabase-pydantic","last_synced_at":"2026-04-26T20:01:49.327Z","repository":{"id":247631591,"uuid":"765898498","full_name":"kmbhm1/supabase-pydantic","owner":"kmbhm1","description":"Generate Pydantic models and other types from Supabase/Postgres/MySQL schemas automatically. Ideal for FastAPI, Supabase, and rapid prototyping.","archived":false,"fork":false,"pushed_at":"2026-04-23T12:40:24.000Z","size":1422,"stargazers_count":74,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-04-23T14:33:09.042Z","etag":null,"topics":["fastapi","mysql","postgres","pydantic-models","pydantic-v2","python","python3","sqlalchemy","supabase"],"latest_commit_sha":null,"homepage":"https://kmbhm1.github.io/supabase-pydantic","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kmbhm1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"kmbhm1","custom":["paypal.me/kmbhm1","venmo.com/u/kmbhm1"]}},"created_at":"2024-03-01T20:54:24.000Z","updated_at":"2026-04-23T12:39:31.000Z","dependencies_parsed_at":"2024-07-24T15:17:23.361Z","dependency_job_id":"63692617-3633-40f6-bab5-07fc41385eab","html_url":"https://github.com/kmbhm1/supabase-pydantic","commit_stats":null,"previous_names":["kmbhm1/supabase-pydantic"],"tags_count":89,"template":false,"template_full_name":null,"purl":"pkg:github/kmbhm1/supabase-pydantic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmbhm1%2Fsupabase-pydantic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmbhm1%2Fsupabase-pydantic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmbhm1%2Fsupabase-pydantic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmbhm1%2Fsupabase-pydantic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmbhm1","download_url":"https://codeload.github.com/kmbhm1/supabase-pydantic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmbhm1%2Fsupabase-pydantic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32310804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T19:15:34.056Z","status":"ssl_error","status_checked_at":"2026-04-26T19:15:15.467Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","mysql","postgres","pydantic-models","pydantic-v2","python","python3","sqlalchemy","supabase"],"created_at":"2024-09-24T13:40:53.024Z","updated_at":"2026-04-26T20:01:49.299Z","avatar_url":"https://github.com/kmbhm1.png","language":"Python","funding_links":["https://github.com/sponsors/kmbhm1","paypal.me/kmbhm1","venmo.com/u/kmbhm1"],"categories":[],"sub_categories":[],"readme":"# Supabase Pydantic Schemas\n\n[![PyPI Version](https://img.shields.io/pypi/v/supabase-pydantic)](https://pypi.org/project/supabase-pydantic/)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/supabase-pydantic)\n](https://anaconda.org/conda-forge/supabase-pydantic)\n[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)\n![GitHub License](https://img.shields.io/github/license/kmbhm1/supabase-pydantic)\n[![codecov](https://codecov.io/github/kmbhm1/supabase-pydantic/graph/badge.svg?token=PYOJPJTOLM)](https://codecov.io/github/kmbhm1/supabase-pydantic)\n![PePy Downloads](https://static.pepy.tech/badge/supabase-pydantic)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/supabase-pydantic)\n\nA 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.\n\nCurrently, this is ideal for integrating [FastAPI](https://fastapi.tiangolo.com/) with [supabase-py](https://supabase.com/docs/reference/python/introduction) as a primary use-case, but more updates are coming! This project is inspired by the TS [type generating](https://supabase.com/docs/guides/api/rest/generating-types) capabilities of supabase cli. Its aim is to provide a similar experience for Python developers.\n\n\u003e **📣 NEW (Aug 2025)**: MySQL support! Generate models directly from MySQL databases with the `--db-type mysql` flag. [See the docs](https://kmbhm1.github.io/supabase-pydantic/examples/mysql-support/)\n\u003e\n\u003e **📣 NEW (Aug 2025)**: SQLAlchemy models with Insert and Update variants for better type safety. [Learn more](https://kmbhm1.github.io/supabase-pydantic/examples/sqlalchemy-models/)\n\n## Installation\n\n```bash\n# Install with pip\n$ pip install supabase-pydantic\n\n# Or with conda\n$ conda install -c conda-forge supabase-pydantic\n```\n\n## Configuration\n\nCreate a `.env` file with your database connection details:\n\n```bash\nDB_NAME=\u003cyour_db_name\u003e\nDB_USER=\u003cyour_db_user\u003e\nDB_PASS=\u003cyour_db_password\u003e\nDB_HOST=\u003cyour_db_host\u003e\nDB_PORT=\u003cyour_db_port\u003e\n```\n\n## Usage\n\n### Generate Pydantic Models\n\nExample with full command output (using a local connection):\n\n```bash\n$ sb-pydantic gen --type pydantic --framework fastapi --local\n\n2025-08-18 15:47:42 - INFO - supabase_pydantic.db.connection:check_connection:72 - PostGres connection is open.\n2025-08-18 15:47:42 - INFO - supabase_pydantic.db.connection:construct_tables:136 - Processing schema: public\n2025-08-18 15:47:42 - INFO - supabase_pydantic.db.connection:__exit__:105 - PostGres connection is closed.\n2025-08-18 15:47:42 - INFO - supabase_pydantic.cli.commands.gen:gen:239 - Generating Pydantic models...\n2025-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\n2025-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\n```\n\n### Common Commands\n\n**Using a database URL:**\n```bash\n$ sb-pydantic gen --type pydantic --framework fastapi --db-url postgresql://postgres:postgres@127.0.0.1:54322/postgres\n```\n\n**Generating models for specific schemas:**\n```bash\n$ sb-pydantic gen --type pydantic --framework fastapi --local --schema extensions --schema auth\n```\n\n**Generate SQLAlchemy models:**\n```bash\n$ sb-pydantic gen --type sqlalchemy --local\n```\n\n**Using MySQL:**\n```bash\n$ sb-pydantic gen --type pydantic --framework fastapi --db-type mysql --db-url mysql://user:pass@localhost:3306/dbname\n```\n\n### Makefile Integration\n\n```makefile\n# Makefile examples for both Pydantic and SQLAlchemy generation\n\ngen-pydantic:\n    @echo \"Generating FastAPI Pydantic models...\"\n    @sb-pydantic gen --type pydantic --framework fastapi --dir ./entities/fastapi --local\n\ngen-sqlalchemy:\n    @echo \"Generating SQLAlchemy ORM models...\"\n    @sb-pydantic gen --type sqlalchemy --dir ./entities/sqlalchemy --local\n\n# Generate all model types at once\ngen-all: gen-pydantic gen-sqlalchemy\n    @echo \"All models generated successfully.\"\n```\n\nFor full documentation, visit [our docs site](https://kmbhm1.github.io/supabase-pydantic/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmbhm1%2Fsupabase-pydantic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmbhm1%2Fsupabase-pydantic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmbhm1%2Fsupabase-pydantic/lists"}