mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
prepare_connection() now takes datasette and database args, refs #678
This commit is contained in:
parent
d3f2fade88
commit
6303ea5048
5 changed files with 16 additions and 8 deletions
|
|
@ -340,12 +340,18 @@ The full list of available plugin hooks is as follows.
|
|||
|
||||
.. _plugin_hook_prepare_connection:
|
||||
|
||||
prepare_connection(conn)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
prepare_connection(conn, database, datasette)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``conn`` - sqlite3 connection object
|
||||
The connection that is being opened
|
||||
|
||||
``database`` - string
|
||||
The name of the database
|
||||
|
||||
``datasette`` - :ref:`datasette`
|
||||
You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``
|
||||
|
||||
This hook is called when a new SQLite database connection is created. You can
|
||||
use it to `register custom SQL functions <https://docs.python.org/2/library/sqlite3.html#sqlite3.Connection.create_function>`_,
|
||||
aggregates and collations. For example:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue