Skip to main content

A lightweight, decorator-based query performance tracking library for Python applications. Monitor and analyze database query performance with ease.

Project description

🐍 pyquerytracker

pyquerytracker is a lightweight Python utility to track and analyze database query performance using simple decorators. It enables developers to gain visibility into SQL execution time, log metadata, and export insights in JSON format — with optional FastAPI integration and scheduled reporting.


🚀 Features

  • ✅ Easy-to-use decorator to track function execution (e.g., SQL queries)
  • ✅ Capture runtime, function name, args, return values, and more

TODO Features

  • ✅ Export logs to JSON or CSV
  • ✅ FastAPI integration to expose tracked metrics via REST API
  • ✅ Schedule periodic exports using APScheduler
  • ✅ Plug-and-play with any Python database client (SQLAlchemy, psycopg2, etc.)
  • ✅ Modular and extensible design

📦 Installation

pip install pyquerytracker

Usage

Basic Usage

import time
from pyquerytracker import TrackQuery

@TrackQuery()
def run_query():
    time.sleep(0.3)  # Simulate SQL execution
    return "SELECT * FROM users;"

run_query()

Output

2025-06-14 14:23:00,123 - pyquerytracker - INFO - Function run_query executed successfully in 305.12ms

With Configure

import logging
from pyquerytracker.config import configure

configure(
    slow_log_threshold_ms=200,     # Log queries slower than 200ms
    slow_log_level=logging.DEBUG   # Use DEBUG level for slow logs
)

Output

2025-06-14 14:24:45,456 - pyquerytracker - WARNING - Slow execution: run_query took 501.87ms

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

pyquerytracker-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyquerytracker-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file pyquerytracker-0.1.0.tar.gz.

File metadata

  • Download URL: pyquerytracker-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyquerytracker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c4529ee4bf5eac3c13d4957785ec148832ac2d64556789a7954921c912507ae
MD5 cafdfd7881d37060ad819e0b2688f8b5
BLAKE2b-256 04d9f13ddc2051e34e11c0622e39cf98d62de52b96dfced0fa922bbe1a62211e

See more details on using hashes here.

File details

Details for the file pyquerytracker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyquerytracker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyquerytracker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c57ccf417e8688a34b5085e3ff5fc1831c1aeb51bb11eec052b5c35b81774c38
MD5 fb28069ed6df9d2d83b6b04d7c779622
BLAKE2b-256 e0b14873c101c59c29fcdcef1f74918963bcbeb044a4b18b21716581025cb438

See more details on using hashes here.

Supported by

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