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.1.1.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

datamodels-0.1.1-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: datamodels-0.1.1.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for datamodels-0.1.1.tar.gz
Algorithm Hash digest
SHA256 168555f6b464e0576684997e88e39d12a6356c766cd1c6d76cc61e6b42f1bff9
MD5 e76677f1f2b152939163ba880f67f1d8
BLAKE2b-256 23bf9b5f5b76b3ebbd04377cc56e4ebf9da795760ad2e22bd7015756a4351362

See more details on using hashes here.

File details

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

File metadata

  • Download URL: datamodels-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for datamodels-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b0c47f96140afd4e4f5e8cc1ac9ae3d0c4f3871120dccd6c9067c9d7e4ba47a7
MD5 c58e275db0aaea63c10de4e2b99aacbd
BLAKE2b-256 551e26750ca52d856df9bf8170a693d86fcfd9a3e09b970d0bbbe356be13da93

See more details on using hashes here.

Supported by

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