A python client for interacting with PostgREST APIs.
Project description
# Pypgrest
A python client for interacting with PostgREST APIs.
## Installation
```
$ pip install pypgrest
```
## Usage
```python
>>> from pypgrest import Postgrest
>>> pgrest = Postgrest("https://api.tacos.com", auth="secretsalsa")
# See postgrest docs for supported query params
>>> params = {
"select" : "name,tortilla,cost",
"tortilla" : "is.corn",
"limit" : 100
}
# Supported methods are select, insert, update, and upsert
>>> pgrest.select(params=params)
[{ "name" : "al pastor", "tortilla" : "corn", "cost" : "2.01" }, ... ]
>>> payload = [{ "id" : 23, "cost" : "2.25" }, { "id" : 26, "cost" : "1.25" }]
>>> pgrest.upsert(payload)
[{ "id" : 23, "cost" : "2.25", "name" : "al pastor", ... }, ... ]
# You can inspect the `Requests` response object like so:
>>> pgrest.res.status_code
201
# If results are paginated the client will continue to request until the specified
# limit (default 1000) is met.
>>> pgrest.select(params={"limit" : 1000})
```
## License
As a work of the City of Austin, this project is in the public domain within the United States.
Additionally, we waive copyright and related rights of the work worldwide through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
A python client for interacting with PostgREST APIs.
## Installation
```
$ pip install pypgrest
```
## Usage
```python
>>> from pypgrest import Postgrest
>>> pgrest = Postgrest("https://api.tacos.com", auth="secretsalsa")
# See postgrest docs for supported query params
>>> params = {
"select" : "name,tortilla,cost",
"tortilla" : "is.corn",
"limit" : 100
}
# Supported methods are select, insert, update, and upsert
>>> pgrest.select(params=params)
[{ "name" : "al pastor", "tortilla" : "corn", "cost" : "2.01" }, ... ]
>>> payload = [{ "id" : 23, "cost" : "2.25" }, { "id" : 26, "cost" : "1.25" }]
>>> pgrest.upsert(payload)
[{ "id" : 23, "cost" : "2.25", "name" : "al pastor", ... }, ... ]
# You can inspect the `Requests` response object like so:
>>> pgrest.res.status_code
201
# If results are paginated the client will continue to request until the specified
# limit (default 1000) is met.
>>> pgrest.select(params={"limit" : 1000})
```
## License
As a work of the City of Austin, this project is in the public domain within the United States.
Additionally, we waive copyright and related rights of the work worldwide through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for pypgrest-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d549b126b81ba485c4c8103a5280955179c994a33bc8c8c3fe7605a1fa560d95 |
|
MD5 | 5bc61bd9b9ece28943d59d9ba41b3a5b |
|
BLAKE2b-256 | 8cd33e4ea1242a5086300f4f936e39f82dd6b01a64a1236a64568d1f77712149 |