SQLAlchemy Extension for PyApp
Project description
Let us handle the boring stuff!
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyApp-SQLAlchemy-1.0.1.tar.gz
.
File metadata
- Download URL: pyApp-SQLAlchemy-1.0.1.tar.gz
- Upload date:
- Size: 4.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | f97df5094ec8a4d8c67b09ad5fa5bf0950552ddaee467a1ed1ceb4ded4c5612e |
|
MD5 | 809878c28afd86ee75353dd45578c82f |
|
BLAKE2b-256 | 248977cbc08b32301b62fc28a94cd8b9347e206cfa785fe06e8ea0ad270d74ce |
File details
Details for the file pyApp_SQLAlchemy-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pyApp_SQLAlchemy-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa42a92c735286321005b46af3594a9d7662197fe303d3835a8f6fd701a2d14e |
|
MD5 | ac97458c3fca2ac5ef1743e0fe45b257 |
|
BLAKE2b-256 | febfaf42fd4524d71a83138a0edf1148596fefb97c61ae70a0f397f0cffb32fc |