sqltap
raw JSON → 0.3.11 verified Fri May 01 auth: no python
sqltap is a profiling and introspection library for applications using SQLAlchemy, providing a web-based UI to inspect SQL queries, their frequency, and execution time. The latest version is 0.3.11, released on PyPI with a stable but low-maintenance status.
pip install sqltap Common errors
error ModuleNotFoundError: No module named 'sqltap' ↓
cause sqltap is not installed or the environment is incorrect.
fix
pip install sqltap
error AttributeError: module 'sqltap' has no attribute 'start' ↓
cause Wrong import pattern: importing sqltap incorrectly (e.g., from sqltap import sqltap) leads to missing attributes.
fix
Use
import sqltap then sqltap.start(). error Report generation fails with 'No module named flask' ↓
cause sqltap.report() tries to use Flask/Jinja2 internally; without Flask, it raises an ImportError.
fix
pip install flask
Warnings
gotcha sqltap.start() returns a profiler object that must be passed to sqltap.stop() - if you forget the return value and use None, the profiler won't be stopped correctly. ↓
fix Always capture the return value of sqltap.start() and pass it to sqltap.stop().
gotcha The HTML report uses Flask/Jinja2 templates; if you do not have Flask installed, the report generation may fail. Make sure to install Flask or handle the exception. ↓
fix Install Flask: pip install flask
deprecated sqltap has not seen updates in several years and may be incompatible with newer SQLAlchemy versions (e.g., 2.0+). The last release was 0.3.11 in 2016. ↓
fix Consider alternative profiling tools like sqlalchemy event listeners or APM solutions.
Imports
- sqltap wrong
from sqltap import sqltapcorrectimport sqltap
Quickstart
import sqltap
from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory:')
profiler = sqltap.start()
# run your SQLAlchemy queries here
engine.execute('SELECT 1')
statistics = sqltap.stop(profiler)
sqltap.report(statistics, "report.html")