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.1.tar.gz (10.0 kB view hashes)

Uploaded Source

Built Distribution

dataclass_mortar-0.1.1-py3-none-any.whl (13.2 kB view hashes)

Uploaded Python 3

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