Skip to content

Commit

Permalink
RequestBuilder.select() now accepts columns as *args
Browse files Browse the repository at this point in the history
  • Loading branch information
lqmanh committed Aug 8, 2020
1 parent 1200265 commit 8901f86
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@

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

#### Changed

Expand Down
40 changes: 37 additions & 3 deletions README.md
Expand Up @@ -18,11 +18,45 @@ PostgREST client for Python. This library provides an ORM interface to PostgREST
$ poetry add git+https://github.com/lqmanh/postgrest_py.git#v0.1.1
```

#### With Pip

## USAGE

## DOCUMENTATION
### Getting started

```py
import asyncio
from postgrest_py import PostgrestClient

async def main():
async with PostgrestClient("http://localhost:3000") as client:
r = await client.from_table("countries").select("*")
countries = r.json()

asyncio.run(main())
```

### Create

```py
await client.from_table("countries").insert({
"name": "Việt Nam",
"capital": "Hà Nội",
})
```

### Read

```py
r = await client.from_table("countries").select("id", "name")
countries = r.json()
```

### Update

### Delete

### General filters

### Stored procedures (RPC)

## CHANGELOG

Expand Down
4 changes: 2 additions & 2 deletions postgrest_py/request_builder.py
Expand Up @@ -8,8 +8,8 @@ def __init__(self, session: AsyncClient, path: str) -> None:
self.json = {}
self.http_method = "GET"

def select(self, columns: str):
self.session.params["select"] = columns
def select(self, *columns: str):
self.session.params["select"] = ",".join(columns)
self.http_method = "GET"
return GetRequestBuilder.from_request_builder(self)

Expand Down

0 comments on commit 8901f86

Please sign in to comment.