supabase-pydantic


Namesupabase-pydantic JSON
Version 0.15.5 PyPI version JSON
download
home_pageNone
SummaryA Pydantic(+) model generator for Supabase
upload_time2025-01-27 18:17:10
maintainerNone
docs_urlNone
authorK Boehm
requires_python<4.0,>=3.10
licenseMIT
keywords supabase pydantic fastapi sqlalchemy rest generator schema model
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Supabase Pydantic Schemas

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/supabase-pydantic)
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
![GitHub License](https://img.shields.io/github/license/kmbhm1/supabase-pydantic)
[![codecov](https://codecov.io/github/kmbhm1/supabase-pydantic/graph/badge.svg?token=PYOJPJTOLM)](https://codecov.io/github/kmbhm1/supabase-pydantic)
![PyPI - Downloads](https://img.shields.io/pypi/dm/supabase-pydantic)


A project for generating Pydantic (& other) models from Supabase (& other) databases. Currently, 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 a 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.

## Installation

We recommend installing the package using pip:

```bash
$ pip install supabase-pydantic
```

Installing with conda is also available:

```bash
conda install -c conda-forge supabase-pydantic
```

## Configuration

```bash
$ touch .env                                    # create .env file
$ echo "DB_NAME=<your_db_name>" >> .env         # add your postgres db name
$ echo "DB_USER=<your_db_user>" >> .env         # add your postgres db user
$ echo "DB_PASS=<your_db_password>" >> .env     # add your postgres db password
$ echo "DB_HOST=<your_db_host>" >> .env         # add your postgres db host
$ echo "DB_PORT=<your_db_port>" >> .env         # add your postgres db port
```

## Usage

Generate Pydantic models for FastAPI using a local supabase connection:

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

PostGres connection is open.
PostGres connection is closed.
Generating FastAPI Pydantic models...
FastAPI Pydantic models generated successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py
File formatted successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py
```

Or generate with a url:

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

Checking local database connection.postgresql://postgres:postgres@127.0.0.1:54322/postgres
Connecting to database: postgres on host: 127.0.0.1 with user: postgres and port: 54322
PostGres connection is open.
Generating FastAPI Pydantic models...
FastAPI Pydantic models generated successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py
File formatted successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py
```

You can generate Pydantic models for certain schemas in your database using the `--schema` or `--all-schemas` options:

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

This command will generate a BaseModel file for each schema in your database.

For some users, integrating a Makefile command may be more convenient:

```bash
gen-types:
    @echo "Generating FastAPI Pydantic models..."
    @sb-pydantic gen --type pydantic --framework fastapi --dir <your path> --local
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "supabase-pydantic",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "supabase, pydantic, fastapi, sqlalchemy, REST, generator, schema, model",
    "author": "K Boehm",
    "author_email": "kmbhm1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0b/7e/7918228f26b643e58c52da28471fda5c9943f81bae897394695a26a80a22/supabase_pydantic-0.15.5.tar.gz",
    "platform": null,
    "description": "# Supabase Pydantic Schemas\n\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/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![PyPI - Downloads](https://img.shields.io/pypi/dm/supabase-pydantic)\n\n\nA project for generating Pydantic (& other) models from Supabase (& other) databases. Currently, 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 a 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## Installation\n\nWe recommend installing the package using pip:\n\n```bash\n$ pip install supabase-pydantic\n```\n\nInstalling with conda is also available:\n\n```bash\nconda install -c conda-forge supabase-pydantic\n```\n\n## Configuration\n\n```bash\n$ touch .env                                    # create .env file\n$ echo \"DB_NAME=<your_db_name>\" >> .env         # add your postgres db name\n$ echo \"DB_USER=<your_db_user>\" >> .env         # add your postgres db user\n$ echo \"DB_PASS=<your_db_password>\" >> .env     # add your postgres db password\n$ echo \"DB_HOST=<your_db_host>\" >> .env         # add your postgres db host\n$ echo \"DB_PORT=<your_db_port>\" >> .env         # add your postgres db port\n```\n\n## Usage\n\nGenerate Pydantic models for FastAPI using a local supabase connection:\n\n```bash\n$ sb-pydantic gen --type pydantic --framework fastapi --local\n\nPostGres connection is open.\nPostGres connection is closed.\nGenerating FastAPI Pydantic models...\nFastAPI Pydantic models generated successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py\nFile formatted successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py\n```\n\nOr generate with a url:\n\n```bash\n$ sb-pydantic gen --type pydantic --framework fastapi --db-url postgresql://postgres:postgres@127.0.0.1:54322/postgres\n\nChecking local database connection.postgresql://postgres:postgres@127.0.0.1:54322/postgres\nConnecting to database: postgres on host: 127.0.0.1 with user: postgres and port: 54322\nPostGres connection is open.\nGenerating FastAPI Pydantic models...\nFastAPI Pydantic models generated successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py\nFile formatted successfully: /path/to/your/project/entities/fastapi/schema_public_latest.py\n```\n\nYou can generate Pydantic models for certain schemas in your database using the `--schema` or `--all-schemas` options:\n\n```bash\n$ sb-pydantic gen --type pydantic --framework fastapi --local --schema extensions --schema auth\n```\n\nThis command will generate a BaseModel file for each schema in your database.\n\nFor some users, integrating a Makefile command may be more convenient:\n\n```bash\ngen-types:\n    @echo \"Generating FastAPI Pydantic models...\"\n    @sb-pydantic gen --type pydantic --framework fastapi --dir <your path> --local\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Pydantic(+) model generator for Supabase",
    "version": "0.15.5",
    "project_urls": {
        "Homepage": "https://kmbhm1.github.io/supabase-pydantic",
        "Repository": "https://github.com/kmbhm1/supabase-pydantic"
    },
    "split_keywords": [
        "supabase",
        " pydantic",
        " fastapi",
        " sqlalchemy",
        " rest",
        " generator",
        " schema",
        " model"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6342386e13213c089032262aa958972dd437b27b581ce236fe0d8086c860cb8e",
                "md5": "8ff2786c0304bee6f89f1681641d4350",
                "sha256": "174d72eec39ebef74f3759c6ab78a6217be537c8fd5d3fb2bfb4d1af9623951f"
            },
            "downloads": -1,
            "filename": "supabase_pydantic-0.15.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8ff2786c0304bee6f89f1681641d4350",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 39645,
            "upload_time": "2025-01-27T18:17:08",
            "upload_time_iso_8601": "2025-01-27T18:17:08.430242Z",
            "url": "https://files.pythonhosted.org/packages/63/42/386e13213c089032262aa958972dd437b27b581ce236fe0d8086c860cb8e/supabase_pydantic-0.15.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0b7e7918228f26b643e58c52da28471fda5c9943f81bae897394695a26a80a22",
                "md5": "9c2172652b8378eb4a69ed12cc7cf51d",
                "sha256": "9ef37e53da758e347e0ea65bfe356b81c1904057664deb724dc40704a758ddd8"
            },
            "downloads": -1,
            "filename": "supabase_pydantic-0.15.5.tar.gz",
            "has_sig": false,
            "md5_digest": "9c2172652b8378eb4a69ed12cc7cf51d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 33632,
            "upload_time": "2025-01-27T18:17:10",
            "upload_time_iso_8601": "2025-01-27T18:17:10.417698Z",
            "url": "https://files.pythonhosted.org/packages/0b/7e/7918228f26b643e58c52da28471fda5c9943f81bae897394695a26a80a22/supabase_pydantic-0.15.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-27 18:17:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kmbhm1",
    "github_project": "supabase-pydantic",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "supabase-pydantic"
}
        
Elapsed time: 5.88576s