Skip to content

datasette/datasette-public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

datasette-public

PyPI Changelog Tests License

Make selected Datasette databases, tables and queries visible to the public

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-public

Usage

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.

Internals

This plugin uses four tables in the internal database:

  • public_databases - stores the public status of databases and if execute SQL is enabled
  • public_tables - stores the public status of tables
  • public_queries - stores the public status of queries
  • public_audit_log - stores the history of changes to the public status of databases, tables and queries

Development

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

About

Make selected Datasette databases and tables visible to the public

Resources

License

Stars

Watchers

Forks