Skip to main content

Let us handle the boring stuff!

https://img.shields.io/badge/code%20style-black-000000.svg Maintainability

This extension provides a Connection and Session factory for SQLAlchemy to allow database connections to be configured via pyApp settings.

Engine instances are created from a singleton factory to ensure that connection pooling is utilised.

The extension also provides checks to confirm the settings are correct and that the application is able to connect to the database host.

Installation

Install using pip:

pip install pyapp-sqlalchemy

Install using pipenv:

pipenv install pyapp-sqlalchemy

Add pyapp_ext.sqlalchemy into the EXT list in your applications default_settings.py.

Add the DATABASE_ENGINES block into your runtime settings file:

DATABASE_ENGINES = {
    "default": {
        "url": "postgres://user:pass@host:port/database",
    },
}

Usage

The following example creates both Connection and Session instances:

from pyapp_ext.sqlalchemy import get_connection, get_session

# Get connection from default connection pool
cnn = get_connection()

# Get connection from an alternate pool
session = get_session("Alternate")

API

pyapp_ext.sqlalchemy.get_engine(default: str = None) -> Engine

Get named Engine instance (singleton)

pyapp_ext.sqlalchemy.get_connection(default: str = None) -> Connection

Get named Connection instance.

pyapp_ext.sqlalchemy.get_raw_connection(default: str = None)

Get named raw connection, this is the underlying Python DBAPI object.

pyapp_ext.sqlalchemy.get_session(default: str = None) -> Session

Get named Session instance.

Metadata

Release files for pyApp-SQLAlchemy 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyApp-SQLAlchemy 1.0.1
File Size Uploaded
pyApp-SQLAlchemy-1.0.1.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyApp-SQLAlchemy 1.0.1
File Interpreter ABI Platform
pyApp_SQLAlchemy-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / pyApp-SQLAlchemy-1.0.1.tar.gz

Download URL pyApp-SQLAlchemy-1.0.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f97df5094ec8a4d8c67b09ad5fa5bf0950552ddaee467a1ed1ceb4ded4c5612e
BLAKE2b-256 checksum
How to use checksums
248977cbc08b32301b62fc28a94cd8b9347e206cfa785fe06e8ea0ad270d74ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7

Release files / pyApp_SQLAlchemy-1.0.1-py3-none-any.whl

Download URL pyApp_SQLAlchemy-1.0.1-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa42a92c735286321005b46af3594a9d7662197fe303d3835a8f6fd701a2d14e
BLAKE2b-256 checksum
How to use checksums
febfaf42fd4524d71a83138a0edf1148596fefb97c61ae70a0f397f0cffb32fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0

2 release files

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