Skip to main content

Provide an Abstract Base Class for PEP249 compliant databases

Project description

dbapi2abc

This package provides abstract classes to present an interface to PEP249 compliant database Connection and Cursor objects.

This allows you to use type hints on functions handling database connections and cursors without needing to specify the specific backend database engine being used.

from dbapi2abc import Connection, Cursor

class MyObject():
    def __init__(self, db: Connection):
        self.db = db

    def run_some_query(self) -> Cursor:
        cur = self.db.cursor()
        cur.execute("SELECT * FROM Table")
        return cur

Project details


Download files

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

Source Distribution

dbapi2abc-1.1.3.tar.gz (7.0 kB view hashes)

Uploaded Source

Built Distribution

dbapi2abc-1.1.3-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page