Skip to main content

Use dataclasses with SQLAlchemy naturally

Project description

mortar

naturally use dataclasses with Alchemy

Experimental concept for easying the use of Dataclasses with Alchemy. Simple models and relationships work, anything more complicated probly won't.

Usage

Decorate a dataclass with @persist Column definitions are automatically generated based off the field data, relationships are created for any field that had a type of another dataclass. Column definitions can be passed to mortar via the metadata attribute of the field() method (provided by dataclass). Partial Column data can also be passed any other required fields of the column will be generated based off the field definition.

Primary Keys

mortar will try to find the proper primary key for a defined class. It will evaluate the columns in this order to find a primary key:

  1. Checks for predefined key via A partial column definition Column(primary_key=True)
  2. Check for a column named <class_name.lower()>_id
  3. check for an id column name
  4. create and auto increment column designated as primary key

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

dataclass-mortar-0.1.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

dataclass_mortar-0.1.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file dataclass-mortar-0.1.4.tar.gz.

File metadata

  • Download URL: dataclass-mortar-0.1.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2

File hashes

Hashes for dataclass-mortar-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3802da34ab1d11cd48267e11c7bf9e69f1414b6b155540f715c2e8dfb3d8214c
MD5 ed1b5c5881e3fa1f6922cc0f0d9c93a9
BLAKE2b-256 b77f2165a896e923d951e8d1576421fa4f8063b2ddba7b8ac37326d760de9840

See more details on using hashes here.

File details

Details for the file dataclass_mortar-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: dataclass_mortar-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.2

File hashes

Hashes for dataclass_mortar-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a06fbb0e8aa81d51d690e254c8ee876e99aebdff4778c6d0f24f83f6790bdf7b
MD5 617a16c340d5d417360b2cf7b3e3203a
BLAKE2b-256 39d9b0448458041540186e194862368d757d40362758fe36532aa63912c73929

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