Skip to main content

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)

Metadata

Release files for marbaloo_sqlalchemy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marbaloo_sqlalchemy 0.1.0
File Size Uploaded
marbaloo_sqlalchemy-0.1.0.tar.gz 3.0 kB Details

Release files / marbaloo_sqlalchemy-0.1.0.tar.gz

Download URL marbaloo_sqlalchemy-0.1.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b186b299758dbfe9c8762ab57142ee8b50bbdf7e2216e88f9b13ddb2a71676e4
BLAKE2b-256 checksum
How to use checksums
22ab9e4f5ba00340e127bab4393edcec32b9c891e88c0dcc74ab94d50601196b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page