Skip to content

Commit 040ad6c

Browse files
committed
Support RPC
1 parent 1e8166d commit 040ad6c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#### Features
66

77
- Support basic authentication
8+
- Support stored procedures (RPC)
89

910
### v0.1.1
1011

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ PostgREST client for Python. This library provides an ORM interface to PostgREST
1212

1313
### Instructions
1414

15+
#### With Poetry
16+
17+
```sh
18+
$ poetry add git+https://github.com/lqmanh/postgrest_py.git#v0.1.1
19+
```
20+
21+
#### With Pip
22+
1523
## USAGE
1624

1725
## DOCUMENTATION

postgrest_py/client.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from httpx import AsyncClient
1+
from httpx import AsyncClient, Response
22

33
from postgrest_py.request_builder import RequestBuilder
44

@@ -22,7 +22,7 @@ async def __aexit__(self, exc_type, exc, tb) -> None:
2222
async def aclose(self) -> None:
2323
await self.session.aclose()
2424

25-
def auth(self, bearer_token: str, *, username: str = None, password=""):
25+
def auth(self, bearer_token: str, *, username: str = None, password: str = None):
2626
"""Authenticate the request, with either bearer token or basic authentication."""
2727

2828
if username:
@@ -44,3 +44,10 @@ def from_(self, table: str) -> RequestBuilder:
4444
"""Alias to Self.from_table()."""
4545

4646
return self.from_table(table)
47+
48+
async def rpc(self, func: str, params: dict) -> Response:
49+
"""Execute a stored procedure call."""
50+
51+
path = f"/rpc/{func}"
52+
r = await self.session.post(path, json=params)
53+
return r

0 commit comments

Comments
 (0)