datasette-events-db by datasette
README source code
datasette-events-db
Log Datasette events to a database table
Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-events-dbThis plugin depends on Datasette 1.0a8 or higher.
Usage
Once installed, all Datasette events will be logged to a table called datasette_events. This table will be created in the _internal database, but can be moved to another database using the following plugin configuration option:
plugins:
datasette-events-db:
database: my_databaseThe table will be created when Datasette starts up, if it does not already exist.
Table schema
create table if not exists datasette_events (
id integer primary key,
event text,
created text,
actor_id text,
database_name text,
table_name text,
properties text -- JSON other properties
)-
eventis the text name of the event, for examplecreate-table -
createdis an ISO formatted UTC timestamp -
actor_idwill be populated with the ID of the responsible actor, ornullif not available -
database_namewill be thedatabaseproperty recorded by the event, if present -
table_namewill be thetableproperty recorded by the event, if present -
propertieswill be a JSON object containing any other properties recorded by the event
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-events-db
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:
pip install -e '.[test]'To run the tests:
pytest