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.
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
Built Distribution
File details
Details for the file lazy_alchemy-1.0.3.tar.gz
.
File metadata
- Download URL: lazy_alchemy-1.0.3.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c261d931313b9984c002109f3818dc9a32193caefd37cf9178473306582dc636 |
|
MD5 | 33412cc152782b79f9c8c5fd8fc2da0a |
|
BLAKE2b-256 | 923821eef4b81f58d961276fee10e70ec5996128cb7d8e25afab1e723d6d37e4 |
File details
Details for the file lazy_alchemy-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: lazy_alchemy-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de83646d3b21ab2b1b2960940e6cd55c5944a62119ca3df519d10dd52160f8de |
|
MD5 | 2c42477b29cfde86b92846b6604fef38 |
|
BLAKE2b-256 | 9fa490ca690fd776b038dea7397218c872b6a88886569ecade7f358dbb6e8a5a |