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 source https://github.com/atv7/fastapi_queryinspect/tree/main

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_queryinspect-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 c7982c8cf639bf349b027d7e89eb9154442059e6d2db234fc325824fa6ab1204
MD5 c5c9bde4488ed104fdc4f1d905fd2f18
BLAKE2b-256 a5e67e552ad69b239f7e6f0d585be06b3b206833adf816a5f23e8746b971c11b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_queryinspect-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 569bda12296814372b6c264f52f6771df721b80e7956450130042cdfb311983f
MD5 b298c712dc372f9a43ab59cb17e5ea11
BLAKE2b-256 d855342417404383e185cc3ef98a77d7868e076ae9466c9f5fda7fd7b85cf7d8

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