Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonw/datasette-explain
Explain and validate SQL queries as you type them into Datasette
https://github.com/simonw/datasette-explain
datasette datasette-plugin
Last synced: 27 days ago
JSON representation
Explain and validate SQL queries as you type them into Datasette
- Host: GitHub
- URL: https://github.com/simonw/datasette-explain
- Owner: simonw
- License: apache-2.0
- Created: 2023-02-09T01:51:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-28T16:55:57.000Z (9 months ago)
- Last Synced: 2024-05-01T23:17:23.987Z (7 months ago)
- Topics: datasette, datasette-plugin
- Language: Python
- Homepage:
- Size: 132 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# datasette-explain
[![PyPI](https://img.shields.io/pypi/v/datasette-explain.svg)](https://pypi.org/project/datasette-explain/)
[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-explain?include_prereleases&label=changelog)](https://github.com/simonw/datasette-explain/releases)
[![Tests](https://github.com/simonw/datasette-explain/workflows/Test/badge.svg)](https://github.com/simonw/datasette-explain/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-explain/blob/main/LICENSE)Explain SQL queries executed using Datasette
## Installation
Install this plugin in the same environment as Datasette.
```bash
datasette install datasette-explain
```
## UsageThe 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](https://datasette.simonwillison.net/simonwillisonblog?sql=select%0D%0A++blog_tag.tag%2C%0D%0A++blog_blogmark.link_title%2C%0D%0A++blog_blogmark.link_url%0D%0Afrom%0D%0A++blog_blogmark_tags%0D%0A++join+blog_tag+on+tag_id+%3D+blog_tag.id%0D%0A++join+blog_blogmark+on+blog_blogmark_tags.blogmark_id+%3D+blog_blogmark.id%0D%0Aorder+by+blog_blogmark.id+desc).
## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd datasette-explain
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```