Skip to main content

SQLAlchemy factories for pyramid_services

Project description

SQLAlchemy factories for pyramid_services.

This module provides removing SQLAlchemy’s boiler plates from your pyramid application codes.

In your pastedeploy.ini:

sqlalchemy.url = ENGINE://DBUSER:PASSWORD@DBHOST/DBNAME

In your application factory:

config.include('pyramid_services_sqlalchemy')

In your views:

from pyramid_services_sqlalchemy import get_tm_session

def aview(request):
    db = get_tm_session(request)

or you can use request.find_service:

from pyramid_services_sqlalchemy import IDBSession

def aview(request):
    db = request.find_service(IDBSession)

If you want to use multiple connections, pastedeploy.ini:

sqlalchemy.names = readonly readwrite
sqlalchemy.readonly.url = ENGINE://READ_DBUSER:PASSWORD@DBHOST/DBNAME
sqlalchemy.readwrite.url = ENGINE://WRITE_DBUSER:PASSWORD@DBHOST/DBNAME

and in your views:

from pyramid_services_sqlalchemy import get_tm_session

def aview(request):
    db = get_tm_session(request, name='readonly')

def a_write_view(request):
    db = get_tm_session(request, name='readwrite')

Change History

0.1.1 - 2018-08-11

  • Update README

0.1 - 2018-08-11

  • Initial release.

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 pyramid-services-sqlalchemy, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size pyramid_services_sqlalchemy-0.1.1-py2.py3-none-any.whl (3.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pyramid_services_sqlalchemy-0.1.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page