supabase-pydantic


Namesupabase-pydantic JSON
Version 0.14.4 PyPI version JSON
download
home_pagehttps://kmbhm1.github.io/supabase-pydantic
SummaryA Pydantic(+) model generator for Supabase
upload_time2024-08-22 17:25:56
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/09/61/7d22c9437b42de5c5b0062c85fd91d3b2d689fa0d44f7eaa365046287506/supabase_pydantic-0.14.4.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.4",
    "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": "4f28ecc1b90dfd39f0e86bc4411dfe1bbda61a1f88e8a202d3c3b3db1fa0f212",
                "md5": "757fdf47f049afcae1f105053c7ae7a5",
                "sha256": "1f3f1fb2200951e058801b5f753c6e2413e3a67c6c2a98fea5e778ced407d6d5"
            },
            "downloads": -1,
            "filename": "supabase_pydantic-0.14.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "757fdf47f049afcae1f105053c7ae7a5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 39452,
            "upload_time": "2024-08-22T17:25:55",
            "upload_time_iso_8601": "2024-08-22T17:25:55.663722Z",
            "url": "https://files.pythonhosted.org/packages/4f/28/ecc1b90dfd39f0e86bc4411dfe1bbda61a1f88e8a202d3c3b3db1fa0f212/supabase_pydantic-0.14.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09617d22c9437b42de5c5b0062c85fd91d3b2d689fa0d44f7eaa365046287506",
                "md5": "e5f8b81d11c3b5e68be4005f98798585",
                "sha256": "f03afad0a7ac83249349ab11e78e24dc34bcbcfb44f3dded3074051ad085a552"
            },
            "downloads": -1,
            "filename": "supabase_pydantic-0.14.4.tar.gz",
            "has_sig": false,
            "md5_digest": "e5f8b81d11c3b5e68be4005f98798585",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 33976,
            "upload_time": "2024-08-22T17:25:56",
            "upload_time_iso_8601": "2024-08-22T17:25:56.717741Z",
            "url": "https://files.pythonhosted.org/packages/09/61/7d22c9437b42de5c5b0062c85fd91d3b2d689fa0d44f7eaa365046287506/supabase_pydantic-0.14.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-22 17:25:56",
    "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.63416s