mirror of
https://github.com/simonw/datasette.git
synced 2026-06-06 09:07:00 +02:00
Warn once when writing to temporary internal database
The internal database defaults to a temporary file that is deleted on shutdown. Plugin writes that expect persistence currently vanish silently. Detect such writes via an `internal_ephemeral_writes()` context manager in `datasette.database`: Datasette wraps `_refresh_schemas` (its own catalog/metadata writes) with the marker, and `Database.execute_write_fn` prints a one-time stderr warning when a write hits a `is_temp_disk` database without the marker set. The warning recommends restarting with `--internal path/to/file.db` for persistence.
This commit is contained in:
parent
aa84fe008d
commit
2e014cda80
4 changed files with 156 additions and 37 deletions
|
|
@ -2037,6 +2037,8 @@ Plugin authors are asked to practice good etiquette when using the internal data
|
|||
3. Use temporary tables or shared in-memory attached databases when possible.
|
||||
4. Avoid implementing features that could expose private data stored in the internal database by other plugins.
|
||||
|
||||
If a plugin writes to the default temporary internal database, Datasette prints a one-time warning to standard error noting that the data will be lost on shutdown and recommending the ``--internal path/to/file.db`` flag for persistence. Datasette suppresses this warning for its own catalog and metadata writes, which are recreated on every startup.
|
||||
|
||||
.. _internals_internal_schema:
|
||||
|
||||
Internal database schema
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue