pony-rest
A subset implementation of PostgREST.
You should read PostgREST and PonyORM first.
Install
pip install pony-rest
Example
Edit entities.py:
from pony.orm import *
db = Database()
class Person(db.Entity):
name = Required(str)
age = Required(int)
cars = Set('Car')
class Car(db.Entity):
make = Required(str)
model = Required(str)
owner = Required(Person)
then:
python -m pony_rest
or via wsgi:
gunicorn pony_rest
How to use this server to do CRUD
T=localhost:3333
# create new Person
curl -H 'content-type: application/json' -d '{"name": "foo", "age": 10}' $T/person
# read Person list
curl localhost:18000/person
# update Person where id is 1
curl -H 'content-type: application/json' -X PATCH -d '{"age": 10}' "$T/person?id=eq.1"
# delete Person where id is 1
curl -X DELETE "$T/person?id=eq.1"
Connect your database
Install module pyyaml, then create a configure file: database.yaml in your working directory, likes:
provider: sqlite
filename: ":memory:"
create_db: true
create_tables: true
...and see database.yaml in this repo to find more.
Note: only the first block configurations in yaml file is used for database, you could leave the old configurations in next blocks.
Lots TODO...
Metadata
Release files for pony-rest 3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pony-rest-3.1.tar.gz | 4.9 kB | Details |
Release files / pony-rest-3.1.tar.gz
| Download URL | pony-rest-3.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
008e4f6fb96449f80d3786073f921b64b0c2c92e7ef0e33b9850e7e2d8ae3c68
|
|
BLAKE2b-256 checksum How to use checksums |
bfdb3aec9279d3cc4427dd4e8646c6a929ba3daaf23fb9306fba2286ef71020f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2
|