Skip to main content

SQLAlchemy load option that loads only from persisted session instances

Project description

sqlalchemy-sessionload

PyPI - Downloads GitHub license Codecov Routine Checks

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:

from sqlalchemy_sessionload import SQLAlchemySessionLoad

Session = sessionmaker(...)
SQLAlchemySessionLoad(Session)

Simple Query

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.

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

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_sessionload-1.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

sqlalchemy_sessionload-1.0.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_sessionload-1.0.0.tar.gz.

File metadata

File hashes

Hashes for sqlalchemy_sessionload-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6ee244e8b9965dcb0d260ba02131ab1133893fe6a70c269cd10158409493af74
MD5 5906d9a7b04b271df5ba830d89422827
BLAKE2b-256 0f6e334b2bb0303d081438e8fcfac4f005446e3086443c1fd5c6462d64567c96

See more details on using hashes here.

File details

Details for the file sqlalchemy_sessionload-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_sessionload-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1081409e0442898909e22770b740ae57be757fba5a90b07b3d607e9dfafb81bb
MD5 173e4d7445ecb1c1432a29107490eb2d
BLAKE2b-256 1ec70517f3a9c475a5d43a2822468fc96cc58d620ede9fded76dd6271c7c68bb

See more details on using hashes here.

Supported by

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