Schemapy
Schemapy allows you to generate objects for centralized database access. You define the schema for your API, the code that needs to be executed, then the validation part is dealt with for you. Everything is then encapsulated in a single object.
Schemapy relies on PyDAL for schema definition but is not tied to it.
See documentation for more informations.
Installation
pip install schemapy
Usage
Using PyDAL:
from schemapy import API, DAL, Field
from datetime import datetime, timedelta
db = DAL('sqlite:memory')
db.define_table(
'users',
Field('name', type='string', required=True),
Field('created_on', type='date')
)
db.define_table(
'posts',
Field('subject', type='string', required=True),
Field('author', type='reference users', required=True),
Field('created_on', type='date'),
Field('content', type='text', required=True)
)
api = API(db)
@api.as_action(
type='read',
request=[
Field('begin', type='date', required=True),
Field('end', type='date', required=True)
],
response=db.posts
)
def select_posts_by_date(db, req, action):
query = (db.posts.created_on >= req.begin) | (db.posts.created_on <= req.end)
return db(query).select()
now = datetime.now()
result = api.select_posts_by_date(
begin=now - timedelta(days=1),
end=now
)
print(list(result))
Metadata
Release files for schemapy 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| schemapy-0.2.4.tar.gz | 6.6 kB | Without provenance | Details for schemapy-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| schemapy-0.2.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for schemapy-0.2.4-py2.py3-none-any.whl |
Total release size: 17.1 kB
Release files / schemapy-0.2.4.tar.gz
| Download URL | schemapy-0.2.4.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d21e9cd627e42b0f2bee883ce48fcda7a1550328191fe4c2cef7ea33681966a0
|
|
BLAKE2b-256 checksum How to use checksums |
9ab5b679384ce43931f31971710ce648e59fd54342027d31b097ad65cf7baa39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / schemapy-0.2.4-py2.py3-none-any.whl
| Download URL | schemapy-0.2.4-py2.py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b4a79ad1ad30c392afdcf3d7db9ccaea201ce7bd95627ed03c097e8a01c859a2
|
|
BLAKE2b-256 checksum How to use checksums |
66637835412cdc05268f10aecc4fa0144a4fd0e6f6304f6e3431c8b2ee88ee09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for schemapy 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.