Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

SQLAlchemy Extension for PyApp

Project description

Let us handle the boring stuff! 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.


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

Add the DATABASE_ENGINES block into your runtime settings file:

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


The URI is a defined by SQLAlchemy see the documentation. In addition to the url any argument that can be provided to sqlalchemy.engines.create_engine can be provided.


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")


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.

Project details

Download files

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

Files for pyApp-SQLAlchemy, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pyApp_SQLAlchemy-1.0.1-py3-none-any.whl (8.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pyApp-SQLAlchemy-1.0.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page