Skip to main content

A middlewere to help find n+1 queries in sqlalchemy.

Project description

FastAPI / SQLAlchemy N+1 query middleware

A FastAPI middleware to find N+1 queries in development. This middleware helps developers identify and fix N+1 query issues in their FastAPI applications. It provides logging information on the query and the number of N+1 query occurrences. This is helpful in identifying and fixing N+1 query issues.

This middleware should probably not be used in production, but it can be useful in development.

Installation

Pip Install:

pip install fastapi-nplusone

UV install:

uv install fastapi-nplusone

Poetry install:

poetry add fastapi-nplusone

Usage

You probably want to disable this middleware in production.

from fastapi import FastAPI
from fastapi_nplusone import NPlusOne

app = FastAPI()
if not app.debug:
    app.add_middleware(NPlusOne)

Tests

To run the tests:

uv run pytest ./tests

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_nplusone-0.0.1b2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

fastapi_nplusone-0.0.1b2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_nplusone-0.0.1b2.tar.gz.

File metadata

  • Download URL: fastapi_nplusone-0.0.1b2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_nplusone-0.0.1b2.tar.gz
Algorithm Hash digest
SHA256 0519b8708aab82776b6dc730d0d04d50cd4071424d3560ab83b7b057178a34dd
MD5 639080d5165e2e52fae5b74d6076094f
BLAKE2b-256 9835e6d2972c0f60e251af10693b5f53a9d29e86c189ea6249237a35d9d2a283

See more details on using hashes here.

File details

Details for the file fastapi_nplusone-0.0.1b2-py3-none-any.whl.

File metadata

  • Download URL: fastapi_nplusone-0.0.1b2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastapi_nplusone-0.0.1b2-py3-none-any.whl
Algorithm Hash digest
SHA256 a59abdc78b7bbac83367218afccc601af300dcb238b61ddd770940f927aca2d5
MD5 a978480709c2cb01aed2118b9f7260f5
BLAKE2b-256 e0020f24403f0341959639de5c30d63d374d5b60d067fe8dac7917a8eeef9490

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