Skip to main content

fastapi async sqlalchemy profiler

Project description

PyPI - Version Static Badge

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.1.tar.gz (109.1 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.1-py3-none-any.whl (122.4 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for fastapi_async_sql_profiler-0.1.4.1.tar.gz
Algorithm Hash digest
SHA256 648e32141ea8bbaa9eb0c00dba190349409b7d30c5a97caaffc79ebbab004ae2
MD5 f474ffe625dd83a92b059f4b3a0f0605
BLAKE2b-256 d7154621efe323b967206a67a1438fac6dd52457edc7cbcc47adba7fade67d23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_async_sql_profiler-0.1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1a356dd4f6d977df489d03cb89d5aeee9135053bddc613728cf208b72f843db
MD5 156b5c40e65a9b8fe9a3602bac9e63eb
BLAKE2b-256 3a1d2d2dd1956ef123e575774991f76b2922ac142bf629710a8c25fbdebaf514

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