Documentation for Datasette() constructor, closes #1563

This commit is contained in:
Simon Willison 2021-12-17 18:19:36 -08:00
commit 7c8f8aa209
2 changed files with 22 additions and 1 deletions

View file

@ -196,6 +196,27 @@ Datasette class
This object is an instance of the ``Datasette`` class, passed to many plugin hooks as an argument called ``datasette``.
You can create your own instance of this - for example to help write tests for a plugin - like so:
.. code-block:: python
from datasette.app import Datasette
# With no arguments a single in-memory database will be attached
datasette = Datasette()
# The files= argument can load files from disk
datasette = Datasette(files="/path/to/my-database.db")
# Pass metadata as a JSON dictionary like this
datasette = Datasette(files="/path/to/my-database.db", metadata={
"databases": {
"my-database": {
"description": "This is my database"
}
}
})
.. _datasette_databases:
.databases