home / docs / sections

sections: plugin_hooks:plugin-hook-database-actions

This data as json

id page ref title content breadcrumbs references
plugin_hooks:plugin-hook-database-actions plugin_hooks plugin-hook-database-actions database_actions(datasette, actor, database, request) datasette - Datasette class You can use this to access plugin configuration options via datasette.plugin_config(your_plugin_name) , or to execute SQL queries. actor - dictionary or None The currently authenticated actor . database - string The name of the database. request - Request object The current HTTP request. Populates an actions menu on the database page. This example adds a new database action for creating a table, if the user has the edit-schema permission: from datasette import hookimpl @hookimpl def database_actions(datasette, actor, database): async def inner(): if not await datasette.permission_allowed( actor, "edit-schema", resource=database, default=False, ): return [] return [ { "href": datasette.urls.path( "/-/edit-schema/{}/-/create".format( database ) ), "label": "Create a table", } ] return inner Example: datasette-graphql , datasette-edit-schema ["Plugin hooks", "Action hooks"] [{"href": "https://datasette.io/plugins/datasette-graphql", "label": "datasette-graphql"}, {"href": "https://datasette.io/plugins/datasette-edit-schema", "label": "datasette-edit-schema"}]
Powered by Datasette · Queries took 1.419ms