Skip to main content

wrap-connection

Easily wrap connections and cursors by using decorators.

Usage example:

A simple usage is this:

def make_connection():
    import sqlite3
    return sqlite3.connect("test.db")

@transact(make_connection, "cur", "con")
def some_operation(person):
    insert_sql = "INSERT INTO persons (id, name) VALUES (?, ?)"
    cur.execute(insert_sql, (person.id, person.name))
    con.commit()

@transact(make_connection)
def some_other_operation():
    select_sql = "SELECT id, name FROM persons"
    result = []
    cursor.execute(select_sql)
    for r in cursor.fetchall():
        result.append(Person(r[0], r[1]))
    return result

Those will delimite a transaction in the some_operation and some_other_operation functions. The make_connection function is used to get the connection for each transaction.

Release files for wrap-connection 2.0.0.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 wrap-connection 2.0.0.0
File Size Uploaded
wrap-connection-2.0.0.0.tar.gz 2.8 kB Details

Release files / wrap-connection-2.0.0.0.tar.gz

Download URL wrap-connection-2.0.0.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
50b4ad939dc7ff1caecce0c735ca93d15784e86326762fc0242066abe16d54b5
BLAKE2b-256 checksum
How to use checksums
65dcfe4358d481e154086ec4fadaaffae6fbe3cb175697d901ac23c5c23f9c13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

2.0.0.0 This release

1 release file

1.0.0.2

1 release file

1.0.0.1

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