This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Context managers for secure and atomic database connectivity

Project Description

Context managers for secure and atomic database connectivity

Rationale

  • Each context being a single atomic process (“either all occur, or nothing occurs”)
  • No manual commit (success), rollback (fail) or close (either)
  • No ORM

Usage

Without Conntext,

conn = sqlite3.connect(":memory:")
try:
    cursor = conn.cursor()
    try:
        cursor.execute("CREATE TABLE person (name)")
        cursor.execute("INSERT INTO person (name) VALUES (?)",
                        ["microamp"])
    except Exception:
        raise
    finally:
        cursor.close()
except Exception:
    conn.rollback()
    raise
else:
    conn.commit()
finally:
    conn.close()

With Conntext,

from conntext import conntext

with conntext.conn(sqlite3.connect(":memory:")) as conn:
   with conntext.cursor(conn.cursor()) as cursor:
        cursor.execute("CREATE TABLE person (name)")
        cursor.execute("INSERT INTO person (name) VALUES (?)",
                       ["microamp"])

License

All the code is licensed under the GNU Lesser General Public License (v3+).

Release History

Release History

This version
History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Conntext-0.1.5.tar.gz (2.4 kB) Copy SHA256 Checksum SHA256 Source Apr 14, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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