This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Adding SQLAlchemy to your application

Use fresco_sqlalchemy.SQLAlchemy to configure your application for use with SQLAlchemy. By default this reads database connection configuration from app, and adds WSGI middleware into your application to manage SQLAlchemy sessions:

from fresco import FrescoApp
from fresco_sqlalchemy import SQLAlchemy

# Create a new Fresco app
app = FrescoApp()

# Connection info is loaded from your application configuration
app.options.SQLALCHEMY = {
    'default': 'driver://user:password@localhost/database',
}

sqlalchemy = SQLAlchemy(app)

You can call your configuration variable something else if you prefer:

app.options.DATABASES = {
    'default': 'driver://user:password@localhost/database',
}
sqlalchemy = SQLAlchemy(app, options_key='DATABASES')

Or skip this step entirely and provide database configuration directly to the constructor:

sqlalchemy = SQLAlchemy(
    app,
    databases={'default': 'driver://user:password@localhost/database',})

Accessing sessions

You can access sqlalchemy sessions directly on the SQLAlchemy object:

sqlalchemy = SQLAlchemy(app)
session = sqlalchemy.getsession()
session.query(...)

Or via fresco.context:

from fresco import context
session = context.sqlalchemy.default
session.query(...)

Multiple connection support

You can specify as many database connection URLs as you want:

app.options.SQLALCHEMY = {
    'staging': 'driver://user:password@localhost/staging_db',
    'production': 'driver://user:password@localhost/production_db',
}

These can be accessed by name, using getsession:

sqlalchemy = SQLAlchemy(app)
sqlalchemy.getsession('staging')

Or from fresco.context:

default_session = context.sqlalchemy.staging
cms_session = context.sqlalchemy.production

Engine configuration

Extra arguments to the SQLAlchemy constructor are passed to SQLAlchemy’s create_engine function. This makes it possible to specify options such as echo=True to log all SQL queries produced by SQLAlchemy:

sqlalchemy = SQLAlchemy(app, echo=True)

0.1 (released 2016-06-30)

  • Initial release
Release History

Release History

0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
fresco-sqlalchemy-0.1.tar.gz (4.9 kB) Copy SHA256 Checksum SHA256 Source Jun 30, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting