Adds a rewrite_sql hook to Datasette.
Warning
This hook is added by monkey-patching Datasette. YOLO, but also, govern yourself accordingly.
Install this plugin in the same environment as Datasette.
datasette install datasette-rewrite-sql
Write a hook like:
from datasette import hookimpl
@hookimpl
def rewrite_sql(sql):
if sql == 'select 123':
return 'select 234'
return sql
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/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest