Pyramid_db documentation!

Installation

easy_install pyramid_db

or:

pip install pyramid_db

Configuration

development.ini or production.ini

; SQLalchemy
pyramid_db.backends = sqlalchemy:default, sqlalchemy:db2, pymongo:default, redis:default, sqllite:default
pyramid_db.backend.sqlalchemy.default.url = postgresql://user:pass@localhost:5432/db1
pyramid_db.backend.sqlalchemy.default.convert_unicode = true
pyramid_db.backend.sqlalchemy.db2.url = postgresql://user:pass@localhost:5432/db2
pyramid_db.backend.sqlalchemy.db2.convert_unicode = true
; MongoDB
pyramid_db.backend.pymongo.default.host = localhost
pyramid_db.backend.pymongo.default.port = 27017
pyramid_db.backend.pymongo.default.user = user
;Redis
pyramid_db.backend.redis.default.host = localhost
pyramid_db.backend.redis.default.port = 6379
pyramid_db.backend.redis.default.db = 0
;SQLLite
pyramid_db.backend.redis.sqllite.default.db = mydatabase.db/
;or
pyramid_db.backend.redis.sqllite.default.db = :memory:

Example

def view(request):
    request.db['sqlalchemy:default']
    request.db['sqlalchemy:db2']
    request.db['pymongo:default']
    request.db['redis:default']
from pyramid.threadlocal import get_current_registry

def func():
    registry = get_current_registry()

    registry.db['sqlalchemy:default']
    registry.db['sqlalchemy:db2']
    registry.db['pymongo:default']
    registry.db['redis:default']
from pyramid_db import get_connection

from mymodels import Model

conn = get_connection('sqlalchemy', 'default')
conn.query(Model).all()

Indices and tables