# datasette-upload-dbs
[![PyPI](https://img.shields.io/pypi/v/datasette-upload-dbs.svg)](https://pypi.org/project/datasette-upload-dbs/)
[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-upload-dbs?include_prereleases&label=changelog)](https://github.com/simonw/datasette-upload-dbs/releases)
[![Tests](https://github.com/simonw/datasette-upload-dbs/workflows/Test/badge.svg)](https://github.com/simonw/datasette-upload-dbs/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-upload-dbs/blob/main/LICENSE)
Upload SQLite database files to Datasette
## Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-upload-dbs
## Configuration
This plugin requires you to configure a directory in which uploaded files will be stored.
On startup, Datasette will automatically load any SQLite files that it finds in that directory. This means it is safe to restart your server in between file uploads.
To configure the directory as `/home/datasette/uploads`, add this to a `metadata.yml` configuration file:
```yaml
plugins:
datasette-upload-dbs:
directory: /home/datasette/uploads
```
Or if you are using `metadata.json`:
```json
{
"plugins": {
"datasette-upload-dbs": {
"directory": "/home/datasette/uploads"
}
}
}
```
You can use `"."` for the current folder when the server starts, or `"uploads"` for a folder relative to that folder. The folder will be created on startup if it does not already exist.
Then start Datasette like this:
datasette -m metadata.yml
The plugin defaults to loading all databases in the configured directory.
You can disable this by adding the following setting:
```
"skip_startup_scan": true
```
## Usage
Only users with the `upload-dbs` permission will be able to upload files. The `root` user has this permission by default - other users can be granted access using permission plugins, see the [Permissions](https://docs.datasette.io/en/stable/authentication.html#permissions) documentation for details.
To start Datasette as the root user, run this:
datasette -m metadata.yml --root
And follow the link that is displayd on the console.
If a user has that permission they will see an "Upload database" link in the navigation menu.
This will take them to `/-/upload-dbs` where they will be able to upload database files, by selecting them or by dragging them onto the drop area.
![Animated demo showing a file being dropped onto a box, then uploading and redirecting to the database page](https://github.com/simonw/datasette-upload-dbs/raw/main/upload-demo.gif)
## Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-upload-dbs
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Raw data
{
"_id": null,
"home_page": "https://github.com/simonw/datasette-upload-dbs",
"name": "datasette-upload-dbs",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Simon Willison",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/50/ce/36a5c48ce583978c2e2c8ad5818c78a4372aa3f7f899a9f67d522abf62ad/datasette_upload_dbs-0.3.2.tar.gz",
"platform": null,
"description": "# datasette-upload-dbs\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-upload-dbs.svg)](https://pypi.org/project/datasette-upload-dbs/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-upload-dbs?include_prereleases&label=changelog)](https://github.com/simonw/datasette-upload-dbs/releases)\n[![Tests](https://github.com/simonw/datasette-upload-dbs/workflows/Test/badge.svg)](https://github.com/simonw/datasette-upload-dbs/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-upload-dbs/blob/main/LICENSE)\n\nUpload SQLite database files to Datasette\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n\n datasette install datasette-upload-dbs\n\n## Configuration\n\nThis plugin requires you to configure a directory in which uploaded files will be stored.\n\nOn startup, Datasette will automatically load any SQLite files that it finds in that directory. This means it is safe to restart your server in between file uploads.\n\nTo configure the directory as `/home/datasette/uploads`, add this to a `metadata.yml` configuration file:\n\n```yaml\nplugins:\n datasette-upload-dbs:\n directory: /home/datasette/uploads\n```\n\nOr if you are using `metadata.json`:\n\n```json\n{\n \"plugins\": {\n \"datasette-upload-dbs\": {\n \"directory\": \"/home/datasette/uploads\"\n }\n }\n}\n```\nYou can use `\".\"` for the current folder when the server starts, or `\"uploads\"` for a folder relative to that folder. The folder will be created on startup if it does not already exist.\n\nThen start Datasette like this:\n\n datasette -m metadata.yml\n\nThe plugin defaults to loading all databases in the configured directory.\n\nYou can disable this by adding the following setting:\n```\n\"skip_startup_scan\": true\n```\n## Usage\n\nOnly users with the `upload-dbs` permission will be able to upload files. The `root` user has this permission by default - other users can be granted access using permission plugins, see the [Permissions](https://docs.datasette.io/en/stable/authentication.html#permissions) documentation for details.\n\nTo start Datasette as the root user, run this:\n\n datasette -m metadata.yml --root\n\nAnd follow the link that is displayd on the console.\n\nIf a user has that permission they will see an \"Upload database\" link in the navigation menu.\n\nThis will take them to `/-/upload-dbs` where they will be able to upload database files, by selecting them or by dragging them onto the drop area.\n\n![Animated demo showing a file being dropped onto a box, then uploading and redirecting to the database page](https://github.com/simonw/datasette-upload-dbs/raw/main/upload-demo.gif)\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n\n cd datasette-upload-dbs\n python3 -m venv venv\n source venv/bin/activate\n\nNow install the dependencies and test dependencies:\n\n pip install -e '.[test]'\n\nTo run the tests:\n\n pytest\n",
"bugtrack_url": null,
"license": "Apache License, Version 2.0",
"summary": "Upload SQLite database files to Datasette",
"version": "0.3.2",
"project_urls": {
"CI": "https://github.com/simonw/datasette-upload-dbs/actions",
"Changelog": "https://github.com/simonw/datasette-upload-dbs/releases",
"Homepage": "https://github.com/simonw/datasette-upload-dbs",
"Issues": "https://github.com/simonw/datasette-upload-dbs/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f10747c722bec64c5f4ca4dc0f5a20e872d427c5091adf60d32f4d985c65edd1",
"md5": "6725b75764ced978080526a3cd14d6cb",
"sha256": "733d298c068b81a0400d7f6f902037ac1da9a07501ff4370dc364a119aabe557"
},
"downloads": -1,
"filename": "datasette_upload_dbs-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6725b75764ced978080526a3cd14d6cb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10735,
"upload_time": "2024-05-03T00:13:03",
"upload_time_iso_8601": "2024-05-03T00:13:03.340608Z",
"url": "https://files.pythonhosted.org/packages/f1/07/47c722bec64c5f4ca4dc0f5a20e872d427c5091adf60d32f4d985c65edd1/datasette_upload_dbs-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "50ce36a5c48ce583978c2e2c8ad5818c78a4372aa3f7f899a9f67d522abf62ad",
"md5": "ee4b5ad628ca435d2b6cd5e83eebf724",
"sha256": "d12052129b81e8dad2e027e49544b589fac2795e704f090de27b5b75bd54b1d9"
},
"downloads": -1,
"filename": "datasette_upload_dbs-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "ee4b5ad628ca435d2b6cd5e83eebf724",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11520,
"upload_time": "2024-05-03T00:13:05",
"upload_time_iso_8601": "2024-05-03T00:13:05.002328Z",
"url": "https://files.pythonhosted.org/packages/50/ce/36a5c48ce583978c2e2c8ad5818c78a4372aa3f7f899a9f67d522abf62ad/datasette_upload_dbs-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-03 00:13:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simonw",
"github_project": "datasette-upload-dbs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "datasette-upload-dbs"
}