Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cldellow/datasette-rewrite-sql
A Datasette hook to inspect/rewrite the SQL users run.
https://github.com/cldellow/datasette-rewrite-sql
datasette datasette-io datasette-plugin
Last synced: 2 months ago
JSON representation
A Datasette hook to inspect/rewrite the SQL users run.
- Host: GitHub
- URL: https://github.com/cldellow/datasette-rewrite-sql
- Owner: cldellow
- License: apache-2.0
- Created: 2023-01-23T04:25:08.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-23T06:11:06.000Z (almost 2 years ago)
- Last Synced: 2024-10-10T22:22:13.873Z (3 months ago)
- Topics: datasette, datasette-io, datasette-plugin
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# datasette-rewrite-sql
[![PyPI](https://img.shields.io/pypi/v/datasette-rewrite-sql.svg)](https://pypi.org/project/datasette-rewrite-sql/)
[![Changelog](https://img.shields.io/github/v/release/cldellow/datasette-rewrite-sql?include_prereleases&label=changelog)](https://github.com/cldellow/datasette-rewrite-sql/releases)
[![Tests](https://github.com/cldellow/datasette-rewrite-sql/workflows/Test/badge.svg)](https://github.com/cldellow/datasette-rewrite-sql/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/cldellow/datasette-rewrite-sql/blob/main/LICENSE)Adds a rewrite_sql hook to Datasette.
> **Warning**
>
> This hook is added by monkey-patching Datasette. YOLO, but also, govern yourself accordingly.## Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-rewrite-sql
## Usage
Write a hook like:
```python
from datasette import hookimpl@hookimpl
def rewrite_sql(sql):
if sql == 'select 123':
return 'select 234'return sql
```## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-rewrite-sql
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest