# 🅛🅐🅩🅨-🅐🅛🅒🅗🅔🅜🅨
*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](https://img.shields.io/pypi/v/lazy_alchemy.svg?style=flat-square&label=version)](https://pypi.org/project/lazy_alchemy/) [![build](https://github.com/joke2k/faker/workflows/Python%20Tests/badge.svg?branch=master&event=push)](https://github.com/satyamsoni2211/lazy_alchemy/actions) [![Licence](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/satyamsoni2211/lazy_alchemy/blob/master/LICENSE)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/lazy_alchemy)
![GitHub repo size](https://img.shields.io/github/repo-size/satyamsoni2211/lazy_alchemy)
![Codecov](https://img.shields.io/codecov/c/github/satyamsoni2211/lazy_alchemy)
[![CodeFactor](https://www.codefactor.io/repository/github/satyamsoni2211/lazy_alchemy/badge)](https://www.codefactor.io/repository/github/satyamsoni2211/lazy_alchemy)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/satyamsoni2211/lazy_alchemy/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/satyamsoni2211/lazy_alchemy/?branch=master)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/satyamsoni2211/lazy_alchemy/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
----
### Compatibility
This package is compatible with Python >= 3.6
### Basic Usage
Install with pip:
```bash
pip install lazy-alchemy
```
```python
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)
```
```python
# 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:
```bash
pytest
```
License
-------
Lazy-Alchemy is released under the MIT License. See the bundled [`LICENSE`](https://github.com/satyamsoni2211/lazy_alchemy/blob/master/LICENSE) file
for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/satyamsoni2211/lazy_alchemy",
"name": "lazy-alchemy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "sqlalchemy,alchemy,mysql,postgres,mssql,sql,sqlite,lazy,performance,orm,mapper,performance,database,lazy,relational,classes,oops,metaclass",
"author": "Satyam Soni",
"author_email": "satyamsoni@hotmail.co.uk",
"download_url": "https://files.pythonhosted.org/packages/92/38/21eef4b81f58d961276fee10e70ec5996128cb7d8e25afab1e723d6d37e4/lazy_alchemy-1.0.3.tar.gz",
"platform": "any",
"description": "# \ud83c\udd5b\ud83c\udd50\ud83c\udd69\ud83c\udd68-\ud83c\udd50\ud83c\udd5b\ud83c\udd52\ud83c\udd57\ud83c\udd54\ud83c\udd5c\ud83c\udd68\n\n*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.\n\nSqlalchemy 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.\n\nLazy-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.\n\n\n\n[![Pypi tag](https://img.shields.io/pypi/v/lazy_alchemy.svg?style=flat-square&label=version)](https://pypi.org/project/lazy_alchemy/) [![build](https://github.com/joke2k/faker/workflows/Python%20Tests/badge.svg?branch=master&event=push)](https://github.com/satyamsoni2211/lazy_alchemy/actions) [![Licence](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/satyamsoni2211/lazy_alchemy/blob/master/LICENSE)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/lazy_alchemy)\n![GitHub repo size](https://img.shields.io/github/repo-size/satyamsoni2211/lazy_alchemy)\n![Codecov](https://img.shields.io/codecov/c/github/satyamsoni2211/lazy_alchemy)\n[![CodeFactor](https://www.codefactor.io/repository/github/satyamsoni2211/lazy_alchemy/badge)](https://www.codefactor.io/repository/github/satyamsoni2211/lazy_alchemy)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/satyamsoni2211/lazy_alchemy/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/satyamsoni2211/lazy_alchemy/?branch=master)\n[![Code Intelligence Status](https://scrutinizer-ci.com/g/satyamsoni2211/lazy_alchemy/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)\n----\n\n### Compatibility\n\n\nThis package is compatible with Python >= 3.6\n\n### Basic Usage\n\n\nInstall with pip:\n\n```bash\n pip install lazy-alchemy\n```\n\n\n```python\n from lazy_alchemy import get_lazy_class\n from sqlalchemy import create_engine\n\n db_engine = create_engine(DB_CONNECT_STRING)\n lazy_db = get_lazy_class(db_engine)\n```\n\n```python\n # SqlAlchemy DB Queries\n db_model = lazy_db.my_db_table_foo\n\n query = session.query(db_model).filter(db_model.foo == \"bar\").all()\n```\n\nTests\n-----\n\nRun tests:\n\n```bash\n pytest\n```\n\n\nLicense\n-------\n\nLazy-Alchemy is released under the MIT License. See the bundled [`LICENSE`](https://github.com/satyamsoni2211/lazy_alchemy/blob/master/LICENSE) file\nfor details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Lazy-Alchemy is a Python package that loads the DB models lazily.",
"version": "1.0.3",
"project_urls": {
"Homepage": "https://github.com/satyamsoni2211/lazy_alchemy"
},
"split_keywords": [
"sqlalchemy",
"alchemy",
"mysql",
"postgres",
"mssql",
"sql",
"sqlite",
"lazy",
"performance",
"orm",
"mapper",
"performance",
"database",
"lazy",
"relational",
"classes",
"oops",
"metaclass"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9fa490ca690fd776b038dea7397218c872b6a88886569ecade7f358dbb6e8a5a",
"md5": "2c42477b29cfde86b92846b6604fef38",
"sha256": "de83646d3b21ab2b1b2960940e6cd55c5944a62119ca3df519d10dd52160f8de"
},
"downloads": -1,
"filename": "lazy_alchemy-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2c42477b29cfde86b92846b6604fef38",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 6115,
"upload_time": "2023-05-18T09:11:06",
"upload_time_iso_8601": "2023-05-18T09:11:06.548633Z",
"url": "https://files.pythonhosted.org/packages/9f/a4/90ca690fd776b038dea7397218c872b6a88886569ecade7f358dbb6e8a5a/lazy_alchemy-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "923821eef4b81f58d961276fee10e70ec5996128cb7d8e25afab1e723d6d37e4",
"md5": "33412cc152782b79f9c8c5fd8fc2da0a",
"sha256": "c261d931313b9984c002109f3818dc9a32193caefd37cf9178473306582dc636"
},
"downloads": -1,
"filename": "lazy_alchemy-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "33412cc152782b79f9c8c5fd8fc2da0a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5450,
"upload_time": "2023-05-18T09:11:09",
"upload_time_iso_8601": "2023-05-18T09:11:09.000567Z",
"url": "https://files.pythonhosted.org/packages/92/38/21eef4b81f58d961276fee10e70ec5996128cb7d8e25afab1e723d6d37e4/lazy_alchemy-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-18 09:11:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "satyamsoni2211",
"github_project": "lazy_alchemy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "sqlalchemy",
"specs": [
[
"==",
"1.4.37"
]
]
},
{
"name": "coverage",
"specs": []
}
],
"lcname": "lazy-alchemy"
}