SQLAlchemy support for cherrypy.
Project description
sqlalchemy support for cherrypy.
Installation
pip install marbaloo_sqlalchemy
Usage
# app.py import marbaloo_sqlalchemy import cherrypy import os from your_models import messages_model marbaloo_sqlalchemy.Plugin(cherrypy.engine).subscribe() cherrypy.tools.db = marbaloo_sqlalchemy.Tool() class Root(object): @cherrypy.expose def index(self): db_session1 = cherrypy.request.db['db1'] db_session2 = cherrypy.request.db['db2'] query = messages_model.insert().values(message='TESTMessage') db_session1.get_bind().execute(query) db_session1.commit() query = messages_model.insert().values(message='TESTMessage') db_session2.get_bind().execute(query) db_session2.commit() config = { 'global': { 'marbaloo_sqlalchemy_db': { 'db1': { 'engine': { 'name_or_url': 'sqlite:///test1.db', 'echo': True, }, 'session': { 'expire_on_commit': True, 'autoflush': True, 'autocommit': False } }, 'db2': { 'engine': { 'name_or_url': 'sqlite:///test2.db', 'echo': True, }, 'session': { 'expire_on_commit': True, 'autoflush': True, 'autocommit': False } }, } }, '/': { 'tools.db.on': True } } cherrypy.quickstart(Root(), '/', config)
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
Close
Hashes for marbaloo_sqlalchemy-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b186b299758dbfe9c8762ab57142ee8b50bbdf7e2216e88f9b13ddb2a71676e4 |
|
MD5 | 87a435b07e73195a81981a76675d67eb |
|
BLAKE2b-256 | 22ab9e4f5ba00340e127bab4393edcec32b9c891e88c0dcc74ab94d50601196b |