Giter Club home page Giter Club logo

sqlalchemy-sessionload's Introduction

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

sqlalchemy-sessionload's People

Contributors

jvllmr avatar renovate[bot] avatar

Watchers

 avatar

sqlalchemy-sessionload's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/benchmark.yaml
  • actions/checkout v4
  • pdm-project/setup-pdm v4
  • benchmark-action/github-action-benchmark v1
.github/workflows/publish.yaml
  • actions/checkout v4
  • pdm-project/setup-pdm v4
.github/workflows/test.yaml
  • actions/checkout v4
  • pdm-project/setup-pdm v4
  • codecov/codecov-action v3
  • actions/checkout v4
  • pdm-project/setup-pdm v4
  • codecov/codecov-action v3
pep621
pyproject.toml
  • sqlalchemy >=1.4
  • dev/sqlalchemy <2.0
  • dev/black >=23.12.0
  • dev/mypy >=1.7.1
  • dev/ruff >=0.1.8
  • dev/pytest >=7.4.3
  • dev/pytest-cov >=4.1.0
  • dev/isort >=5.13.1
  • dev/pycln >=2.4.0
  • dev/pyaphid >=0.3.1
  • dev/pre-commit >=3.5.0
  • dev/sqlalchemy2-stubs >=0.0.2a37
  • dev/faker >=21.0.0
  • dev/pytest-benchmark >=4.0.0
  • dev/sqlalchemy-utils >=0.41.1
  • dev/nox >=2023.4.22

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.