Metadata-Version: 2.1
Name: fastapi-toolbar
Version: 1.0.3
Summary: A debug toolbar for FastAPI.
Home-page: https://github.com/chrismaille/fastapi-toolbar
License: BSD
Keywords: fastapi,debug,profiling
Author: Dani
Author-email: dani@domake.io
Requires-Python: >=3.8,<4
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: BSD License
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Internet
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Dist: Jinja2
Requires-Dist: aiofiles
Requires-Dist: anyio
Requires-Dist: fastapi
Requires-Dist: pyinstrument
Requires-Dist: sqlparse
Project-URL: Repository, https://github.com/chrismaille/fastapi-toolbar
Description-Content-Type: text/markdown

## Welcome to FastAPI-Toolbar

[![PyPI](https://img.shields.io/pypi/v/stela)](https://pypi.org/project/fastpi-toolbar/)
[![Build](https://github.com/chrismaille/fastpi-toolbar/workflows/tests/badge.svg)](https://github.com/chrismaille/fastpi-toolbar/actions)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fastpi-toolbar)](https://www.python.org)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)


> Original work: https://github.com/mongkok/fastapi-debug-toolbar

### Installation

```sh
pip install fastapi-toolbar
```

### Quickstart

Add `DebugToolbarMiddleware` middleware to your FastAPI application:

```py
from debug_toolbar.middleware import DebugToolbarMiddleware
from fastapi import FastAPI

app = FastAPI(debug=True)
app.add_middleware(DebugToolbarMiddleware)
```

### SQLAlchemy

Please make sure to use the *"Dependency Injection"* system as described in the [FastAPI docs](https://fastapi.tiangolo.com/tutorial/sql-databases/#create-a-dependency) and add the `SQLAlchemyPanel` to your panel list:

If you're using a database session generator (using `yield`), please add the full python path of your generators
on the `session_generators` options, when adding the middleware:

```python
# database.py
from typing import Generator
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

engine = create_engine("sqlite://", connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(bind=engine)
Base = declarative_base()

Base.metadata.create_all(bind=engine)

def get_db() -> Generator:
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()  # sqlite will drop tables in memory
        Base.metadata.create_all(bind=engine)  # create tables again
```

```py
# app.py
from fastapi import FastAPI
from debug_toolbar.middleware import DebugToolbarMiddleware

app = FastAPI()

app.add_middleware(
    DebugToolbarMiddleware,
    panels=["debug_toolbar.panels.sqlalchemy.SQLAlchemyPanel"],
    session_generators=["database:get_db"]  # Add the full python path of your session generators
)
```

### Tortoise ORM

Add the `TortoisePanel` to your panel list:

```py
from fastapi import FastAPI
from debug_toolbar.middleware import DebugToolbarMiddleware

app = FastAPI()

app.add_middleware(
    DebugToolbarMiddleware,
    panels=["debug_toolbar.panels.tortoise.TortoisePanel"],
)
```

