Skip to main content

Lazy-Alchemy is a Python package that loads the DB models lazily.

Project description

🅛🅐🅩🅨-🅐🅛🅒🅗🅔🅜🅨

Lazy-Alchemy is a Python package that loads the database models lazily. It's a wrapper on top of sqlalchemy, so the Lazy-Alchemy can be used with any framework or project that use sqlalchemy.

Sqlalchemy loads the entire metadata of all models during the application startup, thus increases the app start up time significantly. In projects where there are 100s of database models, the start up time can be in minutes due to loading of models metadata.

Lazy-Alchemy is an attempt to solve the above mentioned problem. Lazy-Alchemy significantly boosts the start up time from minutes to seconds. It also saves memory by only loading the models "on-demand", and not loading every model.

Pypi tag build Licence


Compatibility

This package is compatible with Python >= 3.6

Basic Usage

Install with pip:

    pip install lazy-alchemy
    from lazy_alchemy import get_lazy_class
    from sqlalchemy import create_engine

    db_engine = create_engine(DB_CONNECT_STRING)
    lazy_db = get_lazy_class(db_engine)
    # SqlAlchemy DB Queries
    db_model = lazy_db.my_db_table_foo

    query = session.query(db_model).filter(db_model.foo == "bar").all()

Tests

Run tests:

    pytest

License

Lazy-Alchemy is released under the MIT License. See the bundled LICENSE file for details.

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

lazy_alchemy-0.0.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

lazy_alchemy-0.0.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file lazy_alchemy-0.0.1.tar.gz.

File metadata

  • Download URL: lazy_alchemy-0.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for lazy_alchemy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 bc25bc2dc5818e9417beb5be395560901d0908496770c9e65df6c88ea8324b52
MD5 04b55d141384be74299ba3bdbf4f91fd
BLAKE2b-256 f5ff5cf89ea123cf6eb8578ef0fac349b419d3db7026c348cbe69b86d8038d3c

See more details on using hashes here.

File details

Details for the file lazy_alchemy-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: lazy_alchemy-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for lazy_alchemy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3efc86283b3f036c0ba5a3ef22d14a2ca05bb44361119ea9977cfca42492dd4
MD5 f80de8c59a6f531f5c80f62a65265582
BLAKE2b-256 b38ad70d2d40a30d30e270062afa118ada8cc1c88d644b7fc04ec5a38f177c8b

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