This release is a pre-release and may not be stable for production use.
supabase_typegen
Generates the typed tables and functions of a Supabase database for the typed
API of postgrest and supabase, so a query names its columns through
attributes the type checker knows and reads its rows as pydantic models.
For every table, view and materialized view it generates:
- a
Rowpydantic model,BooksRow, the rowselect()reads, - an
Insertand anUpdateTypedDict,BooksInsertandBooksUpdate, the only values thevalues()of a typedinsert()andupdate()accept. A key left out of an insert gets the database default, andNonewritesNULL. Columns the database generates itself are left out. A view gets them only when it is insertable or updatable, and a materialized view never, - a
Tablesubclass,Books, thatclient.select(Books)reads in its own schema, with aColumnorNullableColumnper column, aComputedFieldper computed field, and aToOneRelationorToManyRelationper foreign key and computed relationship.
Postgres enums become StrEnums and composite types pydantic models. A
bytea column reads as postgrest.Bytea, bytes decoded from the \x…
hex text PostgREST sends, and takes plain bytes on writes and filters. A
Functions class has a static method per function PostgREST exposes, which
takes the arguments as keyword parameters, optional where the function has a
default, and returns the FunctionCall that client.rpc() runs.
Objects of the public schema are named after themselves, books becomes
Books and BooksRow. Objects of any other schema carry the schema as a
prefix, so inventory.books becomes InventoryBooks and InventoryBooksRow.
A name that is a keyword, or that the module uses itself, gets a trailing
underscore, and a column whose attribute differs from its name is sent under
its name.
Usage
Add supabase_typegen as a development dependency of your project, next to
supabase or postgrest:
uv add --dev supabase_typegen
It reads the GeneratorMetadata document of
@supabase/postgrest-typegen
on standard input and writes the module to standard output:
python -m supabase_typegen < generator_metadata.json > supabase_schema.py
The Supabase CLI introspects the database into that document, so
supabase gen types --lang python runs it in your project once the CLI
supports it. Regenerate the module after every change to the database schema
and commit it. Never edit it by hand.
from supabase import Client
from .supabase_schema import Books, BooksInsert, Functions
def recent_books(client: Client) -> None:
books = (
client.select(Books)
.where(Books.title.like("%Python%") & ~Books.published_on.is_null())
.order(Books.created_at.desc())
.limit(10)
.execute()
)
row: BooksInsert = {"title": "A typed row", "author_id": 2}
client.insert(Books).values(row).execute()
matches = client.rpc(Functions.search_books(query="dune")).execute()
Known limitations
- An optional function argument passed as
Noneis left out, so the function uses its default. ANULLfor such an argument can only be sent withclient.rpc("name", params). - A model field whose attribute differs from its column name, such as
class_forclass, is read and written under the column name, which type checkers also take as its parameter name. Build such a model from its columns:Address.model_validate({"class": "first"}). - A function returning
json,jsonb, a record or rows of a relation that is not generated returnsobject. numericisfloat, ranges andintervalarestr, and arrays assume their elements are notNULL.
Metadata
Release files for supabase_typegen 3.0.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| supabase_typegen-3.0.0a1.tar.gz | 23.3 kB | Without provenance | Details for supabase_typegen-3.0.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| supabase_typegen-3.0.0a1-py3-none-any.whl | Python 3 | none | any | Details for supabase_typegen-3.0.0a1-py3-none-any.whl |
Total release size: 48.7 kB
Release files / supabase_typegen-3.0.0a1.tar.gz
| Download URL | supabase_typegen-3.0.0a1.tar.gz |
|---|---|
| Size | 23.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ba850d7d07f4ea6c5924e1e4d18a6b66c40e0c67e2c965c7777f11e46a95096
|
|
BLAKE2b-256 checksum How to use checksums |
f2845d7b458a1eadd4334c7f45e7fa02ffd0f6bd4ab0830d31489c19efbb2470
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / supabase_typegen-3.0.0a1-py3-none-any.whl
| Download URL | supabase_typegen-3.0.0a1-py3-none-any.whl |
|---|---|
| Size | 25.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dce8e995ddf712c1f40cee17a41b2da02614dfb10c40a844b06d5c12355c08ab
|
|
BLAKE2b-256 checksum How to use checksums |
8462e11867cd41affbeb2f28cb67f68dda31c655482523662ff2c49112199cdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for supabase_typegen 3.0.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.