Name | sqlalchemy-sessionload JSON |
Version |
1.0.2
JSON |
| download |
home_page | |
Summary | SQLAlchemy load option that loads only from persisted session instances |
upload_time | 2024-01-08 08:53:30 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | MIT License
Copyright (c) 2024 Jan Vollmer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
sqlalchemy
session
loader
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# sqlalchemy-sessionload
![PyPI - Downloads](https://img.shields.io/pypi/dd/sqlalchemy-sessionload)
[![GitHub license](https://img.shields.io/github/license/jvllmr/sqlalchemy-sessionload)](https://github.com/jvllmr/sqlalchemy-sessionload/blob/dev/LICENSE)
[![Codecov](https://img.shields.io/codecov/c/github/jvllmr/sqlalchemy-sessionload/dev?style=plastic)](https://app.codecov.io/gh/jvllmr/sqlalchemy-sessionload/tree/dev)
[![Routine Checks](https://github.com/jvllmr/sqlalchemy-sessionload/actions/workflows/test.yaml/badge.svg)](https://github.com/jvllmr/sqlalchemy-sessionload/actions/workflows/test.yaml)
SQLAlchemy load option that loads from persisted session instances.
Supports SQLAlchemy 1.4
## Basic usage
SessionLoad is available for basic queries and relationship loading
Filters and Order By constructs are also supported.
If you miss something you are invited to contribute.
For installation the plugin has to be registered:
```python
from sqlalchemy_sessionload import SQLAlchemySessionLoad
Session = sessionmaker(...)
SQLAlchemySessionLoad(Session)
```
### Simple Query
```python
from sqlalchemy_sessionload import SessionLoad
from project.model import Message
# assignment is needed
# otherwise instances are not saved in session
all_messages = session.query(Message).all()
session_messages = session.query(Message).options(SessionLoad(Message)).all()
```
### Load relationship
Joined loading is currently only available with subqueryload.
```python
from sqlalchemy_sessionload import SessionRelationshipLoad
from project.model import Message, User
import sqlalchemy.orm as sa_orm
# assignment is needed
# otherwise instances are not saved in session
all_users = session.query(User).all()
# users connected to messages are now loaded from session
session_messages = (
session.query(Message)
.options(sa_orm.subqueryload(Message.user), SessionRelationshipLoad(Message.user))
.all()
)
```
## Benchmark
A benchmark is available [here](https://jvllmr.github.io/sqlalchemy-sessionload/dev/bench)
Raw data
{
"_id": null,
"home_page": "",
"name": "sqlalchemy-sessionload",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "sqlalchemy session loader",
"author": "",
"author_email": "Jan Vollmer <jan@vllmr.dev>",
"download_url": "https://files.pythonhosted.org/packages/26/b5/7a81caca119318f24f53d6e2c4addeaba17c12730c623d68d6525dec0945/sqlalchemy_sessionload-1.0.2.tar.gz",
"platform": null,
"description": "# sqlalchemy-sessionload\n\n![PyPI - Downloads](https://img.shields.io/pypi/dd/sqlalchemy-sessionload)\n[![GitHub license](https://img.shields.io/github/license/jvllmr/sqlalchemy-sessionload)](https://github.com/jvllmr/sqlalchemy-sessionload/blob/dev/LICENSE)\n[![Codecov](https://img.shields.io/codecov/c/github/jvllmr/sqlalchemy-sessionload/dev?style=plastic)](https://app.codecov.io/gh/jvllmr/sqlalchemy-sessionload/tree/dev)\n[![Routine Checks](https://github.com/jvllmr/sqlalchemy-sessionload/actions/workflows/test.yaml/badge.svg)](https://github.com/jvllmr/sqlalchemy-sessionload/actions/workflows/test.yaml)\n\nSQLAlchemy load option that loads from persisted session instances.\n\nSupports SQLAlchemy 1.4\n\n## Basic usage\n\nSessionLoad is available for basic queries and relationship loading\n\nFilters and Order By constructs are also supported.\nIf you miss something you are invited to contribute.\n\nFor installation the plugin has to be registered:\n\n```python\nfrom sqlalchemy_sessionload import SQLAlchemySessionLoad\n\nSession = sessionmaker(...)\nSQLAlchemySessionLoad(Session)\n```\n\n### Simple Query\n\n```python\nfrom sqlalchemy_sessionload import SessionLoad\nfrom project.model import Message\n\n# assignment is needed\n# otherwise instances are not saved in session\nall_messages = session.query(Message).all()\n\nsession_messages = session.query(Message).options(SessionLoad(Message)).all()\n```\n\n### Load relationship\n\nJoined loading is currently only available with subqueryload.\n\n```python\nfrom sqlalchemy_sessionload import SessionRelationshipLoad\nfrom project.model import Message, User\nimport sqlalchemy.orm as sa_orm\n\n# assignment is needed\n# otherwise instances are not saved in session\nall_users = session.query(User).all()\n\n\n# users connected to messages are now loaded from session\nsession_messages = (\n session.query(Message)\n .options(sa_orm.subqueryload(Message.user), SessionRelationshipLoad(Message.user))\n .all()\n)\n```\n\n## Benchmark\n\nA benchmark is available [here](https://jvllmr.github.io/sqlalchemy-sessionload/dev/bench)\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2024 Jan Vollmer\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "SQLAlchemy load option that loads only from persisted session instances",
"version": "1.0.2",
"project_urls": {
"Source": "https://github.com/jvllmr/sqlalchemy-sessionload"
},
"split_keywords": [
"sqlalchemy",
"session",
"loader"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a32477c21aee44335eb78171579494872a3d27f1b9668bad5a3c193a27b84288",
"md5": "896ecd4a3eca0484e7e640205a4bf4a9",
"sha256": "5e6e54c2756544e5981cfe4023fa42d122d0873add5658c2a498c97b768ad5d4"
},
"downloads": -1,
"filename": "sqlalchemy_sessionload-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "896ecd4a3eca0484e7e640205a4bf4a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9083,
"upload_time": "2024-01-08T08:53:29",
"upload_time_iso_8601": "2024-01-08T08:53:29.029357Z",
"url": "https://files.pythonhosted.org/packages/a3/24/77c21aee44335eb78171579494872a3d27f1b9668bad5a3c193a27b84288/sqlalchemy_sessionload-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "26b57a81caca119318f24f53d6e2c4addeaba17c12730c623d68d6525dec0945",
"md5": "9d25198d88a303c9d10430a1650d2a4a",
"sha256": "7192497d8db62a0ced3460e400ecb911e16ee03f4e67dfc94485489c732421c6"
},
"downloads": -1,
"filename": "sqlalchemy_sessionload-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "9d25198d88a303c9d10430a1650d2a4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11275,
"upload_time": "2024-01-08T08:53:30",
"upload_time_iso_8601": "2024-01-08T08:53:30.255829Z",
"url": "https://files.pythonhosted.org/packages/26/b5/7a81caca119318f24f53d6e2c4addeaba17c12730c623d68d6525dec0945/sqlalchemy_sessionload-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-08 08:53:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jvllmr",
"github_project": "sqlalchemy-sessionload",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "sqlalchemy-sessionload"
}