Skip to main content

Flatten nested SQLAlchemy model data

Project description

SQLAlchemy Flattener

This tool allows you to have the DX of defining test data with the ORM - nested as deeply as you like - then recursively flattening that data to either python dicts for bulk inserts, or just raw SQL insert statements for maximum seeding speed between tests.

Works really well in conjunction with polyfactory

Usage

$ sqlflat --help

usage: sqlflat [-h] [--format {dict,sql}] instances order output

Flatten SQLAlchemy ORM instances.

positional arguments:
  instances            The module namespace containing the model instances, e.g. `foo.bar.instance_list`
  order                The module namespace containing a sequence of table insert ordering.
  output               The output file path to write the flattened data to.

options:
  -h, --help           show this help message and exit
  --format {dict,sql}  The format to write the data in.

Where insertion_ordering_list is a list of model classes or sqlalchemy.Table instances, but not declarative model instances. Take a look at the examples directory.

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

sqlalchemy_flattener-0.5.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlalchemy_flattener-0.5.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_flattener-0.5.0.tar.gz.

File metadata

File hashes

Hashes for sqlalchemy_flattener-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e2936f16ada95fdd016fc8ff763e01516ad6624b8fed1999dd85a22b8847dd3c
MD5 0b50b42a600fa860e02b801b97479850
BLAKE2b-256 fa41d38daee12c67a1f59265a72e766dd4723cf4f5fefc1bd1ce5dbbcbd8556d

See more details on using hashes here.

File details

Details for the file sqlalchemy_flattener-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_flattener-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf15da25c0ff259726dcb66969f9c94f5bdbfa92e9dce730c3ddff4525d5d8ba
MD5 156d75d17bdfaa2d0683603c7ddc4bd6
BLAKE2b-256 e982702fc2fb4b15efe4f7c137dcbd881e463d6329c50f0ffac4e95ca185db47

See more details on using hashes here.

Supported by

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