Client#
pgrest.async_client.Client (BaseClient)
#
Asyncio compatible PostgREST client.
__init__(self, base_url, *, schema='public', headers={'Accept': 'application/json', 'Content-Type': 'application/json'}, session=None)
special
#
Create a PostgREST client.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url |
str |
base URL of the PostgREST API. |
required |
schema |
str |
Which database schema to use. |
'public' |
headers |
dict[str, str] |
Any headers that have to be sent with every request. |
{'Accept': 'application/json', 'Content-Type': 'application/json'} |
session |
Optional[_AsyncClient] |
instance of httpx.AsyncClient if you want to reuse an existing one. |
None |
aclose(self)
async
#
Close the underlying HTTP transport and proxies.
selection: inherited_members: true
pgrest.base_client.BaseClient
#
auth(self, token=None, *, username=None, password='')
#
Authenticate the client with either bearer token or basic authentication. Bearer token is preferred if both ones are provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token |
Optional[str] |
The bearer token to authenticate with. |
None |
username |
Optional[AnyStr] |
Username |
None |
password |
AnyStr |
Password |
'' |
Returns:
Type | Description |
---|---|
T |
The modified Client instance. |
Exceptions:
Type | Description |
---|---|
ValueError |
if neither authentication scheme is provided. |
schema(self, schema)
#
Switch to another database schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
str |
The name of the new schema to switch to. |
required |
Returns:
Type | Description |
---|---|
T |
The modified Client instance. |
from_(self, table)
#
Perform a table operation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table |
str |
The name of the table to query from. |
required |
Returns:
Type | Description |
---|---|
RequestBuilder |
rpc(self, func, params)
#
Perform a stored procedure call.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
str |
The name of the PostgreSQL stored procedure (function) to run. |
required |
params |
dict |
Named parameters to pass to the function. |
required |
Returns:
Type | Description |
---|---|
FilterRequestBuilder |