Skip to main content

A libray for use with SQLAlchemy to count queires, log queries, etc...

Project description

DBInspector

A Python context manager for use with SQLAlchemy.

Features

  • Count the number of queires issued.
  • Capture/print the statements/queries issued.

Installation

pip install dbinspector

Usage

with DBInspector(conn) as inspector:
    conn.execute("SELECT 1")
    conn.execute("SELECT 1")

    # Get query count
    assert inspector.get_count() == 2

    # Print queries issued
    inspector.print_queries(pretty=True)

    # Example pretty printed output:
    """
    QUERY #1
    ----------
    SELECT 1

    QUERY #2
    ----------
    SELECT 1
    """

API

DBInspector.get_count() -> int

DBInspector.print_queries(pretty=False)

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

dbinspector-0.1.1.tar.gz (2.2 kB view hashes)

Uploaded source

Built Distribution

dbinspector-0.1.1-py3-none-any.whl (3.5 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page