Skip to main content

CherryPy-SQLAlchemy

CherryPy-SQLAlchemy makes it easy to use SQLAlchemy within CherryPy apps.

Credits

This package was primarily created from Sylvain’s SQLAlchemy recipe.

Basic Usage

There are two elements of CherryPy-SQLAlchemy

  1. A CherryPy tool that will create a session for use with each request.

  2. A CherryPy plugin that can maintains information about the database and binds the session to the specific DB.

Here is an example connecting to a sqlite db:

import cherrypy

from app import Root
from app.models import ORMBase
from cp_sqlalchemy import SQLAlchemyTool, SQLAlchemyPlugin


def run():
    cherrypy.tools.db = SQLAlchemyTool()
    cherrypy.tree.mount(Root(), '/', {
        '/': {
            'tools.db.on': True
        }
    })

    SQLAlchemyPlugin(
        cherrypy.engine, ORMBase, 'sqlite:////path/to/file.db'
    )

    cherrypy.engine.start()
    cherrypy.engine.block()

One thin to note is the ORMBase we imported is sqlalchemy.ext.declarative.declarative_base() that was used when creating models.

From there, each request will have access to cherrypy.request.db, which is an instance of a SQLAlchemy session.

There is a more complete example.py in the source.

Metadata

Release files for cp_sqlalchemy 0.5.1

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

Source distribution (sdist)

Source distribution for cp_sqlalchemy 0.5.1
File Size Uploaded Provenance Actions
cp_sqlalchemy-0.5.1.tar.gz 3.4 kB Without provenance Details for cp_sqlalchemy-0.5.1.tar.gz

Release files / cp_sqlalchemy-0.5.1.tar.gz

Download URL cp_sqlalchemy-0.5.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
894f0de45202d0981cf0647c73fe5e07e6b7fcf484ad972a8e4a506a7a39e810
BLAKE2b-256 checksum
How to use checksums
108bf60653db3743821661cc208170c57c409c97600e918c093d24cd45baad11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for cp_sqlalchemy 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.1 This release

1 release file No provenance

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