This release is a pre-release and may not be stable for production use.
postgrest
PostgREST client for Python.
Installation
Needs Python 3.12 or newer and an HTTP client adapter, such as httpx:
uv add postgrest "supabase_utils[httpx]"
# or
pip install postgrest "supabase_utils[httpx]"
Supabase Service Compatibility
Only the latest PostgREST release is guaranteed to work. Older releases are supported on a best-effort basis. If you self-host, upgrade PostgREST when you upgrade this package.
Usage
The client takes the URL of PostgREST and the HTTP session to send requests with. Leaving the context manager closes the session:
import asyncio
from httpx import AsyncClient
from postgrest import AsyncPostgrestClient
from supabase_utils.http.adapters.httpx import AsyncHttpxSession
async def main() -> None:
async with AsyncPostgrestClient(
"http://127.0.0.1:56321/rest/v1", AsyncHttpxSession(AsyncClient())
) as client:
response = await client.from_("countries").select("*").execute()
print(response.data)
asyncio.run(main())
SyncPostgrestClient with an HttpxSession works the same way without await.
The examples below use the async client.
Insert, select, update and delete
countries = client.from_("countries")
await countries.insert({"name": "Việt Nam", "capital": "Hà Nội"}).execute()
response = await countries.select("id", "name").execute()
await countries.update({"capital": "Hà Nội"}).eq("name", "Việt Nam").execute()
await countries.delete().eq("name", "Việt Nam").execute()
An update or delete without a filter raises ValueError before anything is
sent. Call all() to affect every row on purpose:
await client.from_("countries").update({"visited": False}).all().execute()
Reuse a query
Builder methods return a new query and leave the original unchanged, so one base query can branch into several requests:
asian = client.from_("countries").select("id", "name").eq("continent", "Asia")
large = await asian.gte("population", 100_000_000).execute()
small = await asian.lt("population", 1_000_000).execute()
Call a database function
await client.rpc("foobar", {"arg1": "value1", "arg2": "value2"}).execute()
Local development
Start a local PostgREST with the Supabase CLI. It listens on http://127.0.0.1:56321/rest/v1:
supabase --workdir infra start
Metadata
Release files for postgrest 3.0.0a2
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 |
|---|---|---|---|---|
| postgrest-3.0.0a2.tar.gz | 77.0 kB | Without provenance | Details for postgrest-3.0.0a2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| postgrest-3.0.0a2-py3-none-any.whl | Python 3 | none | any | Details for postgrest-3.0.0a2-py3-none-any.whl |
Total release size: 163.1 kB
Release files / postgrest-3.0.0a2.tar.gz
| Download URL | postgrest-3.0.0a2.tar.gz |
|---|---|
| Size | 77.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c2fa657beff9bc297c49355f11fca08d955b48a0d4c2fcf1b9dbefb7cb1d533
|
|
BLAKE2b-256 checksum How to use checksums |
b353abad3f51a01b6efbe8cfeb609bda6127ce1d0667bdac85afe42f55802355
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / postgrest-3.0.0a2-py3-none-any.whl
| Download URL | postgrest-3.0.0a2-py3-none-any.whl |
|---|---|
| Size | 86.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4007d974548ec894afdeba278458a11ab10b1eeb6bc07c698d89312d7ee5764
|
|
BLAKE2b-256 checksum How to use checksums |
b63fd019e757b87a70e7660c6cd604030e068417c012b7b42c59019ad3c73206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.12 {"installer":{"name":"uv","version":"0.13.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for postgrest 3.0.0a2
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.