datasette-explain by simonw

187 downloads this week        Star

README source code

datasette-explain

PyPI Changelog Tests License

Explain SQL queries executed using Datasette

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-explain

Usage

The plugin adds JavaScript to the query editor page which will constantly update the page with information gained from running EXPLAIN QUERY PLAN queries against the entered SQL.

This may result in an error message, or it may show the query plan along with any tables used by the query.

Demo

You can see this plugin in action on datasette.simonwillison.net.

Demo of this plugin - a SQL query shows the explain plan as well as the three tables that were used in the query (their names and columns)

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-explain
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest