Skip to main content

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.

License Development Status Latest release Supported Python versions Supported Python implementations Download format Build status Code test coverage Code Health

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)

Source distribution for schemapy 0.2.4
File Size Uploaded
schemapy-0.2.4.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for schemapy 0.2.4
File Interpreter ABI Platform
schemapy-0.2.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page