Metadata-Version: 2.4
Name: pyramid_debugtoolbar_api_sqlalchemy
Version: 1.0.0
Summary: SQLAlchemy CSV exporting for pyramid_debugtoolbar
Home-page: https://github.com/jvanasco/pyramid_debugtoolbar_api_sqlalchemy
Author: Jonathan Vanasco
Author-email: jvanasco@2xlp.com
License: MIT
Keywords: web,pyramid,sqlalchemy
Classifier: Intended Audience :: Developers
Classifier: Framework :: Pyramid
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.5
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: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: pyramid
Requires-Dist: pyramid_debugtoolbar>=4.0
Requires-Dist: six
Requires-Dist: sqlalchemy
Requires-Dist: setuptools<82; python_version >= "3.7" and python_version < "3.10"
Provides-Extra: testing
Requires-Dist: coverage; extra == "testing"
Requires-Dist: pytest; extra == "testing"
Dynamic: license-file

pyramid_debugtoolbar_api_sqlalchemy
===================================

.. image:: https://github.com/jvanasco/pyramid_debugtoolbar_api_sqlalchemy/workflows/Python%20package/badge.svg
        :alt: Build Status

`pyramid_debugtoolbar_api_sqlalchemy` extends the existing `pyramid_debugtoolbar`
SQLAlchemy Panel to support downloadable CSV files of profiling data.

This package does not replace the default panel, and requires it to be active.

This package is designed for application profile and to be a useful part of test
suites, allowing developers to run a series of tests and log the SQLAlchemy
performance.

If you are using the debugtoolbar directly:

* If SQLAlchemy queries exist on the request, a "SQLAlchemy CSV" tab will appear.
  That will prompt you for queries.

If you are scripting:

* The urls are generated in a machine-friendly format, so you can regex the
  `request_id` off a page and pull it from the API.  this is explained below:


NOTES:
======

This packages requires pyramid_debugtoolbar 4.0 or newer


How to use this package
=======================


Update your ENVIRONMENT.ini file

.. code-block:: python

    debugtoolbar.includes = pyramid_debugtoolbar_api_sqlalchemy

You MUST be using `pyramid_debugtoolbar` with the SQLAlchemy panel enabled.
This just piggybacks on the existing module's work to log queries.

You MUST use `debugtoolbar.includes`.  This will not work properly via `pyramid.includes`

You can access a csv of the SQLAlchemy report via the following url hack:

.. code-block:: python

    url_html = '/_debug_toolbar/{request_id}'
    url_api =  '/_debug_toolbar/api-sqlalchemy/sqlalchemy-{request_id}.csv'
    
The file will be downloaded and offer a content-disposition as:

    sqlalchemy-{request_id}.csv

The CSV columns are:

* execution timing
* SQLAlchemy query
* query params (json encoded)


Configuration
=======================

By default, this package writes CSV files using "UTF-8" encoding.

To change this, use the environment variable `pyramid_debugtoolbar_api_sqlalchemy_encoding`

.. code-block:: shell

	export pyramid_debugtoolbar_api_sqlalchemy_encoding=ascii
