Skip to main content

Models for Pythonistas

Project description

# datamodels

The datamodels package builds on dataclasses and adds the following functionality:

  • .dict() instance method – returns a dict of the data, making it simple to serialize to formats like JSON or YAML.

  • .from_data() class method – create a new instance by passing in an iterable key-value data source (such as a dict). Unlike the regular constructor, this only uses the values in the input data that match fields in the model — others are ignored. This is useful for pulling model data out of a larger data source.

  • @validator decorator to specify data validation methods.

  • .validate() class method – runs the attribute validator methods and returns a dict with the fields that have errors as keys and a list of errors as the values.

The datamodels package is inspired by prior art: Django models and forms, the attrs package by which dataclasses was inspired, and the XML world, where schemas and data validation form a key part of production workflows.

Installation:

`bash pip install datamodels `

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datamodels-0.8.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

datamodels-0.8.2-py2.py3-none-any.whl (12.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file datamodels-0.8.2.tar.gz.

File metadata

  • Download URL: datamodels-0.8.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for datamodels-0.8.2.tar.gz
Algorithm Hash digest
SHA256 bc60d3b8425bd7a9fcb20f7b8dbd4a067d6b99172463732733124acb743c9127
MD5 147a70ed317126561f6ea2ef5e9c35c0
BLAKE2b-256 f1f6096612993054998ab4b276bc0caa85053f551f31cc3a1f01fbd2dd8a1332

See more details on using hashes here.

File details

Details for the file datamodels-0.8.2-py2.py3-none-any.whl.

File metadata

  • Download URL: datamodels-0.8.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for datamodels-0.8.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 91b1ce563fe8f6ecc50bc505c8115397fcdca188957c14b718465ec0c7eeab12
MD5 dbc90ae80b847a7b622dfa4ad1e7eee6
BLAKE2b-256 d40d15cfa81ce24df475413929b552f9c084153bcea6839dea590c76fb97911a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page