Skip to main content

Supabase integration for pydantic

Project description

Supadantic

Supadantic is a small Python library that allows you to manage Supabase tables through Pydantic models. It is very convenient to use in projects based on FastAPI, Flask, and so on.

Installation

Install using pip install -U pydantic. Also, you need to add SUPABASE_URL and SUPABASE_KEY to your env variables.

A Simple example

from supadantic import BaseDBEntity


class User(BaseDBEntity):
    # id field already defined in BaseDBEntity class
    name: str = 'John Doe'

    @classmethod
    def _get_table_name(cls) -> str:
        return 'users'

# Save user
user = User()
user.save()

another_user = User(name='Another name')
another_user.save()

# Get users
User.get_list()

# Get users with name == 'John Doe'
User.get_list(eq={'name': 'John Doe'})

# Get users with name != 'Another name'
User.get_list(neq={'name': 'Another name'})

# Get one user
user = User.get(eq={'id': 1})

# Bulk update
User.bulk_update(ids=[1,2], data={'name': 'New name'})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

supadantic-0.0.2.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

supadantic-0.0.2-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page