Skip to main content

FastAPI middleware to provide metrics on SQL queries per request.

Project description

fastapi_queryinspect

FastAPI-QueryInspect is a FastAPI extension that provides SQL query metrics and analysis per request, inspired by Flask-QueryInspect (https://github.com/noise/flask-queryinspect) and Django-QueryInspect (https://github.com/dobarkod/django-queryinspect). It tracks query performance, identifies slow queries and duplicate table access, and works with SQLAlchemy to offer detailed timing stats and request-level SQL insights

Installation

pip install fastapi-queryinspect

Usage

app = FastAPI()
query_inspect = QueryInspect(app)

Configuration

QueryInspect has the following optional config vars that can be set in Flask's app.config:

Variable Default Description
QUERYINSPECT_ENABLED True False to completely disable QueryInspect
QUERYINSPECT_HEADERS True Enable response header injection
QUERYINSPECT_LOG True Enable logging
QUERYINSPECT_SLOW_THRESHOLD 0.5 Show queries >= 0.5s
QUERYINSPECT_DUPLICATE_LIMIT 5 Show queries after 5 duplicates

Log Format

[SQL] %d queries (%d duplicates), %d ms SQL time, %d ms total request time

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

fastapi_queryinspect-0.1.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

fastapi_queryinspect-0.1.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_queryinspect-0.1.2.tar.gz.

File metadata

  • Download URL: fastapi_queryinspect-0.1.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fastapi_queryinspect-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f8766297a993ed5888b36ed197d8307b0e8bfe60cf91673a358d87f322f7be1d
MD5 95dc96d5a8362ca120c75022be9ae25e
BLAKE2b-256 e188140b8b2cb9399847ab35cda1ace60b5cde51fef40f341504e4997ea10d78

See more details on using hashes here.

File details

Details for the file fastapi_queryinspect-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_queryinspect-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9a22cd7dbb612939643c0c8aa9f243942d27c035ed9d5cb9b779b65a1fe9fc5f
MD5 74ab3b26135bc30716799fe750ed97db
BLAKE2b-256 7eb6284e8a6d666cf0447c36ac73d9d08f9fb38210aca6682752ebdbceb5bb4d

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