https://github.com/cldellow/datasette-mutable-downloads
Enable downloading mutable databases from Datasette
https://github.com/cldellow/datasette-mutable-downloads
Last synced: 5 months ago
JSON representation
Enable downloading mutable databases from Datasette
- Host: GitHub
- URL: https://github.com/cldellow/datasette-mutable-downloads
- Owner: cldellow
- License: apache-2.0
- Created: 2023-02-18T20:09:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-20T02:22:34.000Z (over 3 years ago)
- Last Synced: 2025-10-09T05:40:01.647Z (9 months ago)
- Language: Python
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# datasette-mutable-downloads
[](https://pypi.org/project/datasette-mutable-downloads/)
[](https://github.com/cldellow/datasette-mutable-downloads/releases)
[](https://github.com/cldellow/datasette-mutable-downloads/actions?query=workflow%3ATest)
[](https://github.com/cldellow/datasette-mutable-downloads/blob/main/LICENSE)
Enable downloading mutable databases.
## Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-mutable-downloads
## Usage
You can now download a mutable database on its database page, just as you
can for immutable databases.
Example: https://dux.fly.dev/cooking
## Notes
This is achieved by a somewhat gross monkeypatch of the `DatabaseDownload`
view.
We detect if the database is mutable. If it is, we first create a copy via
[`VACUUM INTO`](https://www.sqlite.org/lang_vacuum.html#vacuum_with_an_into_clause).
We then stream that file to the user, and delete it.
This requires SQLite 3.27.0 or newer (Feb 2019).
> **NOTE**
>
> The act of `VACUUM INTO` could be resource intensive if your
> database is large. If you expose your Datasette to the Internet,
> you may wish to restrict this to only authenticated users.
>
> To do that, add a permissions block in your metadata.json:
>
> ```
> "permissions": {
> "view-database-download": {
> "gh_id": "*"
> }
> }
> ```
## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-mutable-downloads
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest