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

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.1.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.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_queryinspect-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2fe32925dcb8fc02b68e876c755611fc096bde92d5e9e89faaf9dca1d8d7db1a
MD5 6b5aa5c6231d8f6e1b57f163f227d031
BLAKE2b-256 fed5ddfb60241eff318b8435a0cb2210f425bc639303e0703872a38888989557

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_queryinspect-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 777fbae75bcaf4a34c7085df88a45ee485c0d879a013b33c814b4447d7cfc423
MD5 5952508b9e784edd4ef9e685fbd8bbdf
BLAKE2b-256 71016a58883d421132ac465947881ee1069f6fc22ebb0cbbb7e85cc95b1611cf

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