Skip to main content

Part of https://github.com/simonw/datasette-app

Project description

datasette-app-support

PyPI Changelog Tests License

Part of https://github.com/simonw/datasette-app

Installation

Install this plugin in the same environment as Datasette.

$ datasette install datasette-app-support

Using this outside of the context of Datasette.app probably won't work.

API endpoints

This plugin exposes APIs that are called by the Electron wrapper.

All plugins are protected by authentication: they need to be called with a Authorization: Bearer xxx token here the xxx matches the value of the DATASETTE_API_TOKEN environment variable.

/-/auth-app-user

POST /-/auth-app-user
{"redirect": "/-/metadata"}

If a valid Authorization header is passed, sets a signed cookie identifying the user as {"id": "admin"} and redirects them to the specified page.

/-/open-database-file

POST /-/open-database-file
{"path": "/path/to/file.db"}

Attaches a new database file to the running Datasette instance - used by the "Open Database..." menu option.

Returns HTTP 200 status with {"ok": True, "path": "/file"} if it works, 400 with an "error" JSON string message if it fails.

/-/new-empty-database-file

POST /-/new-empty-database-file
{"path": "/path/to/file.db"}

Creates a brand new empty SQLite database file at the specified path and attaches it to the Datasette instance. Used by the "Create Empty Database..." menu option.

Returns HTTP 200 status with {"ok": True, "path": "/file"} if it works, 400 with an "error" JSON string message if it fails.

/-/open-csv-file

POST /-/open-csv-file
{"path": "/path/to/file.csv"}

Imports a CSV or TSV file into the default /temporary in-memory database. Used by the "Open CSV..." menu option.

Returns HTTP 200 status with {"ok": True, "path": "/temporary/table"} if it works, 400 or 500 with an "error" JSON string message if it fails.

/-/import-csv-file

POST /-/import-csv-file
{"path": "/path/to/file.csv", "database": "database_name"}

Permanently imports a CSV or TSV file into the specified database. Used by the "Import CSV..." menu option.

Returns HTTP 200 status with {"ok": True, "path": "/database_name/table"} if it works, 400 or 500 with an "error" JSON string message if it fails.

/-/dump-temporary-to-file

POST /-/dump-temporary-to-file
{"path": "/path/to/backup.db"}

Dumps the contents of the temporary in-memory database to the specified file. This is intended to be used to take a temporary backup when the Datasette server is restarted after a plugin has been installed, see datasette-app/issues/42.

Returns HTTP 200 status with {"ok": True, "path": "/path/to/backup.db"} if it works, 400 or 500 with an "error" JSON string message if it fails.

/-/restore-temporary-to-file

POST /-/restore-temporary-from-file
{"path": "/path/to/backup.db"}

Restores the temporary in-memory database to the contents of the specified file.

Returns HTTP 200 status with {"ok": True, "path": "/path/to/backup.db"} if it works, 400 or 500 with an "error" JSON string message if it fails.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-app-support
python3 -mvenv venv
source venv/bin/activate

Or if you are using pipenv:

pipenv shell

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasette-app-support-0.7.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

datasette_app_support-0.7-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file datasette-app-support-0.7.tar.gz.

File metadata

  • Download URL: datasette-app-support-0.7.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for datasette-app-support-0.7.tar.gz
Algorithm Hash digest
SHA256 9880e5ed762d50d9d1b5a59eeb01501f0628703e569a12351470931fe8ad50aa
MD5 e12a33d8c103db584cfb126bd72d0144
BLAKE2b-256 63d8ca26338cfbad3bf40d8151fdcd280d2892f1d9faeeecc9fe2c8e53ea1a69

See more details on using hashes here.

File details

Details for the file datasette_app_support-0.7-py3-none-any.whl.

File metadata

  • Download URL: datasette_app_support-0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for datasette_app_support-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ccdcbf4c53b8852deeb4f60e71500378d2a4f3655db979b24406f0faebb0b423
MD5 d846ce8edf27b9cc657f2c51ebe2e140
BLAKE2b-256 33a77483f180d9cdcef9fd1bac0ae7652bc29d08068090bad7f03ba41c79963d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page