Skip to content

Commit 8901f86

Browse files
committed
RequestBuilder.select() now accepts columns as *args
1 parent 1200265 commit 8901f86

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Support basic authentication
88
- Support stored procedures (RPC)
9+
- `RequestBuilder.select()` now accepts `columns` as variable-length arguments
910

1011
#### Changed
1112

README.md

+37-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,45 @@ PostgREST client for Python. This library provides an ORM interface to PostgREST
1818
$ poetry add git+https://github.com/lqmanh/postgrest_py.git#v0.1.1
1919
```
2020

21-
#### With Pip
22-
2321
## USAGE
2422

25-
## DOCUMENTATION
23+
### Getting started
24+
25+
```py
26+
import asyncio
27+
from postgrest_py import PostgrestClient
28+
29+
async def main():
30+
async with PostgrestClient("http://localhost:3000") as client:
31+
r = await client.from_table("countries").select("*")
32+
countries = r.json()
33+
34+
asyncio.run(main())
35+
```
36+
37+
### Create
38+
39+
```py
40+
await client.from_table("countries").insert({
41+
"name": "Việt Nam",
42+
"capital": "Hà Nội",
43+
})
44+
```
45+
46+
### Read
47+
48+
```py
49+
r = await client.from_table("countries").select("id", "name")
50+
countries = r.json()
51+
```
52+
53+
### Update
54+
55+
### Delete
56+
57+
### General filters
58+
59+
### Stored procedures (RPC)
2660

2761
## CHANGELOG
2862

postgrest_py/request_builder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def __init__(self, session: AsyncClient, path: str) -> None:
88
self.json = {}
99
self.http_method = "GET"
1010

11-
def select(self, columns: str):
12-
self.session.params["select"] = columns
11+
def select(self, *columns: str):
12+
self.session.params["select"] = ",".join(columns)
1313
self.http_method = "GET"
1414
return GetRequestBuilder.from_request_builder(self)
1515

0 commit comments

Comments
 (0)