Make selected Datasette databases, tables and queries visible to the public
Install this plugin in the same environment as Datasette.
datasette install datasette-public
This plugin can only be used with Datasette 1.0a+ and requires Datasette to be run with a persistent internal database:
datasette --internal internal.db data.db
To grant datasette-public
permission to the root user run the following:
datasette --internal internal.db data.db --root \
-s permissions.datasette-public.id root
New database, table and query action menu items allow users with the datasette-public
permission to toggle databases, tables and queries between public and private.
For databases, users can also select if the ability to execute arbitrary SQL should be exposed to the public.
If a table is public but the database is private, users will not we able to use the ?_where=
parameter on that table.
The interfaces for managing the visibility of databases, tables and queries include an audit log of changes that have been made to their public status.
This plugin uses four tables in the internal database:
public_databases
- stores the public status of databases and if execute SQL is enabledpublic_tables
- stores the public status of tablespublic_queries
- stores the public status of queriespublic_audit_log
- stores the history of changes to the public status of databases, tables and queries
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-public
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
In local development it's useful to run Datasette with everything made private by default:
datasette data.db \
--internal internal.db \
-s allow.id root \
-s permissions.datasette-public.id root \
--root \
--secret fixed \
--reload
To run the tests:
pytest