mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
First working -d based Datasette Library
Refs #417 First proof-of-concept for Datasette Library. Run like this: datasette -d ~/Library Uses a new plugin hook - available_databases() BUT... I don't think this is quite the way I want to go.
This commit is contained in:
parent
9c46f2f21f
commit
947645d847
15 changed files with 201 additions and 18 deletions
|
|
@ -23,4 +23,6 @@ Options:
|
|||
datasette.readthedocs.io/en/latest/config.html
|
||||
--version-note TEXT Additional note to show on /-/versions
|
||||
--help-config Show available config options
|
||||
-d, --dir DIRECTORY Directories to scan for SQLite databases
|
||||
--scan Continually scan directories for new database files
|
||||
--help Show this message and exit.
|
||||
|
|
|
|||
|
|
@ -854,3 +854,25 @@ Your other plugin hooks can then access these settings like so:
|
|||
}
|
||||
|
||||
Be careful not to define an option which clashes with a Datasette default option, or with options provided by another plugin. For this reason we recommend using a common prefix for your plugin, as shown above.
|
||||
|
||||
.. _plugin_hook_available_databases:
|
||||
|
||||
available_databases(datasette)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Return a list of ``(name, database)`` pairs to be added to the available databases.
|
||||
|
||||
``name`` should be a string. ``database`` should be a ``datasette.database.Database`` instance.
|
||||
|
||||
This allows plugins to make databases available from new sources.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from datasette import hookimpl
|
||||
from datasette.database import Database
|
||||
|
||||
@hookimpl
|
||||
def available_databases(datasette):
|
||||
return [
|
||||
("hardcoded_database", Database(datasette, "/mnt/hard_coded.db"))
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue