supabase-pydantic


Namesupabase-pydantic JSON
Version 0.14.6 PyPI version JSON
download
home_pagehttps://kmbhm1.github.io/supabase-pydantic
SummaryA Pydantic(+) model generator for Supabase
upload_time2024-10-30 18:20:23
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/schemas.py
File formatted successfully: /path/to/your/project/entities/fastapi/schemas.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/schemas.py
File formatted successfully: /path/to/your/project/entities/fastapi/schemas.py
```

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": "https://kmbhm1.github.io/supabase-pydantic",
    "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/8e/9f/e7401f838b556cd880ae4c0ca0796180dc17fd44be1820d0561f655a5870/supabase_pydantic-0.14.6.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/schemas.py\nFile formatted successfully: /path/to/your/project/entities/fastapi/schemas.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/schemas.py\nFile formatted successfully: /path/to/your/project/entities/fastapi/schemas.py\n```\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.14.6",
    "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": "",
            "digests": {
                "blake2b_256": "2ec6116093a794bb8945152a0bfd5683938994a8e023819d4d525eb61afbd788",
                "md5": "a397c6237bf9faba3783ad348baca35f",
                "sha256": "9a6788aee27607e516d18b413bb58dd5430727a5676e5b2530a43958c4a6d633"
            },
            "downloads": -1,
            "filename": "supabase_pydantic-0.14.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a397c6237bf9faba3783ad348baca35f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 38455,
            "upload_time": "2024-10-30T18:20:22",
            "upload_time_iso_8601": "2024-10-30T18:20:22.021173Z",
            "url": "https://files.pythonhosted.org/packages/2e/c6/116093a794bb8945152a0bfd5683938994a8e023819d4d525eb61afbd788/supabase_pydantic-0.14.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e9fe7401f838b556cd880ae4c0ca0796180dc17fd44be1820d0561f655a5870",
                "md5": "5665ad74f22b57cd4dfa800ddea42af6",
                "sha256": "d1f2b3600885fac2938cd405218cf4c22defcad305a6cf5b2bf2eeaaf4aef12f"
            },
            "downloads": -1,
            "filename": "supabase_pydantic-0.14.6.tar.gz",
            "has_sig": false,
            "md5_digest": "5665ad74f22b57cd4dfa800ddea42af6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 33009,
            "upload_time": "2024-10-30T18:20:23",
            "upload_time_iso_8601": "2024-10-30T18:20:23.920101Z",
            "url": "https://files.pythonhosted.org/packages/8e/9f/e7401f838b556cd880ae4c0ca0796180dc17fd44be1820d0561f655a5870/supabase_pydantic-0.14.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-30 18:20:23",
    "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: 0.42183s