You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

schemapy

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schemapy

Centralize database access

0.2.4
pipPyPI
Maintainers
1

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.

.. _documentation: https://schemapy.readthedocs.io .. _PyDAL: https://github.com/web2py/pydal

.. image:: https://img.shields.io/pypi/l/schemapy.svg?style=flat-square :target: https://pypi.python.org/pypi/schemapy/ :alt: License

.. image:: https://img.shields.io/pypi/status/schemapy.svg?style=flat-square :target: https://pypi.python.org/pypi/schemapy/ :alt: Development Status

.. image:: https://img.shields.io/pypi/v/schemapy.svg?style=flat-square :target: https://pypi.python.org/pypi/schemapy/ :alt: Latest release

.. image:: https://img.shields.io/pypi/pyversions/schemapy.svg?style=flat-square :target: https://pypi.python.org/pypi/schemapy/ :alt: Supported Python versions

.. image:: https://img.shields.io/pypi/implementation/schemapy.svg?style=flat-square :target: https://pypi.python.org/pypi/schemapy/ :alt: Supported Python implementations

.. image:: https://img.shields.io/pypi/wheel/schemapy.svg?style=flat-square :target: https://pypi.python.org/pypi/schemapy :alt: Download format

.. image:: https://travis-ci.org/link-society/schemapy.svg?branch=master&style=flat-square :target: https://travis-ci.org/link-society/schemapy :alt: Build status

.. image:: https://coveralls.io/repos/github/link-society/schemapy/badge.svg?style=flat-square :target: https://coveralls.io/r/link-society/schemapy :alt: Code test coverage

.. image:: https://landscape.io/github/link-society/schemapy/master/landscape.svg?style=flat-square :target: https://landscape.io/github/link-society/schemapy/master :alt: Code Health

Installation

.. code-block:: text

pip install schemapy

Usage

Using PyDAL:

.. code-block:: python

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))

Keywords

schema api database

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts