Skip to main content

fastapi async sqlalchemy profiler

Project description

fastapi-async-sql-profiler

Installation

pip install fastapi-async-sql-profiler

Usage:

  1. Update the database connection URL in the .env file.
SQL_PROFILER_DATABASE_URL=<database_connection_url>
  1. Declare the middleware in your main FastAPI file.
from fastapi_async_sql_profiler import SQLProfilerMiddleware
from fastapi_async_sql_profiler import profiler_router
from fastapi_async_sql_profiler import init_db
# don't forget to import the engine that your project uses
from YOUR_PROJECT import engine

# add SQL Profiler [begin]
app.include_router(profiler_router)
task = asyncio.create_task(init_db())

SQL_PROFILER_PASS_ROUTE_STARTSWITH = [
    '/docs',
    '/openapi.json',
    '/favicon.ico',
]
app.add_middleware(
    SQLProfilerMiddleware,
    engine=engine,  # specify the engine that your project uses
    skip_route_startswith=SQL_PROFILER_PASS_ROUTE_STARTSWITH,
)
# add SQL Profiler [end]

Endpoints

Please paste the following endpoints in the browser to see the results.

  1. /profiler/pages/requests: Displays all captured requests with pagination support.

  2. /profiler/pages/request/{id}: Detailed information about a specific request identified by its ID.

  3. /profiler/pages/request/{id}/sql: Queries related to a specific request identified by its ID.

  4. /profiler/pages/request/{id}/sql/{id}: Details of a specific query identified by its ID.

Contributing

Contributions are welcome! If you find a bug or have suggestions for improvements, please open an issue or submit a pull request.

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_async_sql_profiler-0.1.4.0.tar.gz (108.9 kB view details)

Uploaded Source

Built Distribution

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

fastapi_async_sql_profiler-0.1.4.0-py3-none-any.whl (122.2 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_async_sql_profiler-0.1.4.0.tar.gz.

File metadata

File hashes

Hashes for fastapi_async_sql_profiler-0.1.4.0.tar.gz
Algorithm Hash digest
SHA256 953c2517edf87e1355b2f0b4de28df48c834bb87e11e4e1654dda79ac382014a
MD5 7cbe8f888cd4df6e9224a6bda018885c
BLAKE2b-256 17cb99719b7afa7bf7fae59390ea1b94d59fa441c5252e6edc3f49251d004a55

See more details on using hashes here.

File details

Details for the file fastapi_async_sql_profiler-0.1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_async_sql_profiler-0.1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 867b897613c128919fbb7e73de0b0b1ea13ccce1d188b2a69f5b1d909df14ca8
MD5 0d4026f0b6743e4ff4cd96d554c9af88
BLAKE2b-256 8c3fab254160fbecac4f4d580cadf45e3f6022ef93684f6586e76dcaacf4d559

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