Skip to main content

Assorted utility functions to support working with SQLAlchemy.

Function auto_session(func)

Decorator to run a function in a session is not presupplied.

Class ORM

A convenience base class for an ORM class.

This defines a .Base attribute which is a new DeclarativeBase and provides various Session related convenience methods.

Subclasses must define their own .Session factory in their own __init__, for example:

self.Session = sessionmaker(bind=engine)

Function orm_auto_session(method)

Decorator to run a method in a session derived from self.orm if a session is not presupplied. Intended to assist classes with a .orm attribute.

Function with_session(func, *a, orm=None, session=None, **kw)

Call func(*a,session=session,**kw), creating a session if required.

This is the inner mechanism of @auto_session and ORM.auto_session_method.

Parameters:

  • func: the function to call
  • a: the positional parameters
  • orm: optional ORM class with a .session() context manager method
  • session: optional existing ORM session

One of orm or session must be not None; if session is None then one is made from orm.session() and used as a context manager. The session is also passed to func as the keyword parameter session to support nested calls.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cs.sqlalchemy_utils-20190517.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file cs.sqlalchemy_utils-20190517.tar.gz.

File metadata

  • Download URL: cs.sqlalchemy_utils-20190517.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for cs.sqlalchemy_utils-20190517.tar.gz
Algorithm Hash digest
SHA256 63ebffdca03bec39276bbad80545afc48f480440491413ca35fb9a7ee4626e14
MD5 52341c2de44426dcd1dd74e423331bd9
BLAKE2b-256 6befe7645c8cdeda875a50c80edd2039d5174fcf405a4a14a87112bd2171d0ae

See more details on using hashes here.

Release history Release notifications | RSS feed

20260531

2 files

20250308

2 files

20241122

2 files

20241005

2 files

20240723

2 files

20230612

2 files

20230212

2 files

20220606

2 files

20220311

1 file

20210420

1 file

20210322

1 file

20210321

1 file

20210306

1 file

20201025

1 file

20190830.1

1 file

20190830

1 file

20190812

1 file

20190526

1 file

This release

20190517 This release

1 file

20190403

1 file

20190319.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page