Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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 pae.sqlalchemy

Install using pipenv:

pipenv install pae.sqlalchemy

Add pae.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 pae.sql_alchemy 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

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

Get named Engine instance (singleton)

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

Get named Connection instance.

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

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

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

Get named Session instance.

Download files

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

Source Distribution

pyApp-SQLAlchemy-1.0b1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyApp_SQLAlchemy-1.0b1-py2.py3-none-any.whl (4.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyApp-SQLAlchemy-1.0b1.tar.gz.

File metadata

  • Download URL: pyApp-SQLAlchemy-1.0b1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pyApp-SQLAlchemy-1.0b1.tar.gz
Algorithm Hash digest
SHA256 cc58201a83ee32e54f7a979eb6ba4685c86036a6960fd4d421ea78c62e5dad3c
MD5 707e402129bb86af21f800cf29f3fc95
BLAKE2b-256 1770041e079179390304943d3e04581d2b0dd77052b7dd45fedff4be6c939edf

See more details on using hashes here.

File details

Details for the file pyApp_SQLAlchemy-1.0b1-py2.py3-none-any.whl.

File metadata

  • Download URL: pyApp_SQLAlchemy-1.0b1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for pyApp_SQLAlchemy-1.0b1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 52fe6c55d56510c6bc1168c55614f874c4b1047facf130acd0b89d2fb1126aaf
MD5 0246d3c29e836de1be9778016230a2ab
BLAKE2b-256 1c3a9c6b5c747ff27de5dd4c4f2b331cb6ab8d06467e817a453b9a0a8002bfb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page