Skip to content

Commit 6493154

Browse files
authored
Namespace change (#114)
* docs: add rtd config * chore: move to the postgrest namespace * chore: move constants to its own file * chore: pass headers/params down builders We were earlier modifying session.headers/session.params for every query. Instead of this we follow what postgrest-js does and add headers and params as arguments to the query builders, and pass them down the chain of builders, and finally pass it to the execute method. * docs: add examples * fix: order of filters in examples * docs: add example for closing the client
1 parent 29e91a2 commit 6493154

39 files changed

+435
-227
lines changed

.readthedocs.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
3+
build:
4+
os: ubuntu-20.04
5+
tools:
6+
python: "3.9"
7+
8+
python:
9+
install:
10+
- requirements: docs/requirements.txt
11+
12+
13+
- method: pip
14+
path: .

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ clean_infra:
2525
run_tests: tests
2626

2727
build_sync:
28-
poetry run unasync postgrest_py tests
28+
poetry run unasync postgrest tests

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pip install postgrest-py
5454

5555
```py
5656
import asyncio
57-
from postgrest_py import AsyncPostgrestClient
57+
from postgrest import AsyncPostgrestClient
5858

5959
async def main():
6060
async with AsyncPostgrestClient("http://localhost:3000") as client:
@@ -74,24 +74,27 @@ await client.from_("countries").insert({ "name": "Việt Nam", "capital": "Hà N
7474

7575
```py
7676
r = await client.from_("countries").select("id", "name").execute()
77-
countries = r.json()
77+
countries = r.data
7878
```
7979

8080
### Update
8181

8282
```py
83-
await client.from_("countries").eq("name", "Việt Nam").update({"capital": "Hà Nội"}).execute()
83+
await client.from_("countries").update({"capital": "Hà Nội"}).eq("name", "Việt Nam").execute()
8484
```
8585

8686
### Delete
8787

8888
```py
89-
await client.from_("countries").eq("name", "Việt Nam").delete().execute()
89+
await client.from_("countries").delete().eq("name", "Việt Nam").execute()
9090
```
9191

9292
### General filters
9393

9494
### Stored procedures (RPC)
95+
```py
96+
await client.rpc("foobar", {"arg1": "value1", "arg2": "value2"}).execute()
97+
```
9598

9699
## DEVELOPMENT
97100

docs/api/client.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ To run any queries, the first step is to construct a client.
55

66
The library offers both synchronous and asynchronous clients.
77

8-
.. autoclass:: postgrest_py.AsyncPostgrestClient
8+
.. autoclass:: postgrest.AsyncPostgrestClient
99
:members:
1010
:inherited-members:
1111

12-
.. autoclass:: postgrest_py.SyncPostgrestClient
12+
.. autoclass:: postgrest.SyncPostgrestClient
1313
:members:
1414
:inherited-members:

docs/api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Exceptions
22
==========
33

4-
.. autoexception:: postgrest_py.APIError
4+
.. autoexception:: postgrest.APIError
55
:members:

docs/api/filters.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ filter data during queries.
1818
All the filter methods return a modified instance of the filter builder, allowing fluent chaining of filters.
1919

2020

21-
.. autoclass:: postgrest_py.AsyncFilterRequestBuilder
21+
.. autoclass:: postgrest.AsyncFilterRequestBuilder
2222
:members:
23+
:undoc-members:
2324
:inherited-members:
25+
:member-order: bysource
2426

25-
.. autoclass:: postgrest_py.SyncFilterRequestBuilder
27+
.. autoclass:: postgrest.SyncFilterRequestBuilder
2628
:members:
29+
:undoc-members:
2730
:inherited-members:
31+
:member-order: bysource

docs/api/request_builders.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ Request Builders
88
.. warning::
99
These classes are not meant to be constructed by the user.
1010

11-
.. autoclass:: postgrest_py.AsyncRequestBuilder
11+
.. autoclass:: postgrest.AsyncRequestBuilder
1212
:members:
1313
:inherited-members:
1414

15-
.. autoclass:: postgrest_py.AsyncSelectRequestBuilder
15+
.. autoclass:: postgrest.AsyncSelectRequestBuilder
1616
:members:
1717
:inherited-members:
1818

19-
.. autoclass:: postgrest_py.AsyncQueryRequestBuilder
19+
.. autoclass:: postgrest.AsyncQueryRequestBuilder
2020
:members:
2121
:inherited-members:
2222

23-
.. autoclass:: postgrest_py.SyncRequestBuilder
23+
.. autoclass:: postgrest.SyncRequestBuilder
2424
:members:
2525
:inherited-members:
2626

27-
.. autoclass:: postgrest_py.SyncSelectRequestBuilder
27+
.. autoclass:: postgrest.SyncSelectRequestBuilder
2828
:members:
2929
:inherited-members:
3030

31-
.. autoclass:: postgrest_py.SyncQueryRequestBuilder
31+
.. autoclass:: postgrest.SyncQueryRequestBuilder
3232
:members:
3333
:inherited-members:

docs/api/responses.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Responses
22
=========
33

4-
Once a query is run, the postgrest_py parses the server's response into an APIResponse object.
4+
Once a query is run, the library parses the server's response into an APIResponse object.
55

6-
.. autoclass:: postgrest_py.APIResponse
6+
.. autoclass:: postgrest.APIResponse
77
:members:

docs/api/types.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Types
33

44
Some type aliases and enums used in the library.
55

6-
.. autoclass:: postgrest_py.types.CountMethod
6+
.. autoclass:: postgrest.types.CountMethod
77
:members:
88

9-
.. autoclass:: postgrest_py.types.Filters
9+
.. autoclass:: postgrest.types.Filters
1010
:members:
1111

12-
.. autoclass:: postgrest_py.types.RequestMethod
12+
.. autoclass:: postgrest.types.RequestMethod
1313
:members:
1414

15-
.. autoclass:: postgrest_py.types.ReturnMethod
15+
.. autoclass:: postgrest.types.ReturnMethod
1616
:members:

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717

1818
# -- Project information -----------------------------------------------------
19-
import postgrest_py
19+
import postgrest
2020

2121
project = "postgrest-py"
22-
version = postgrest_py.__version__
22+
version = postgrest.__version__
2323
release = version
2424
copyright = (
2525
"2022, Anand Krishna, Daniel Reinón García, Joel Lee, Leynier Gutiérrez González"
@@ -64,4 +64,4 @@
6464
# Add any paths that contain custom static files (such as style sheets) here,
6565
# relative to this directory. They are copied after the builtin static files,
6666
# so a file named "default.css" will overwrite the builtin "default.css".
67-
html_static_path = ["_static"]
67+
html_static_path = []

0 commit comments

Comments
 (0)