Skip to main content

Datasette plugin for modifying table schemas

Project description

datasette-edit-schema

PyPI Changelog Tests License

Datasette plugin for modifying table schemas

Features

  • Add new columns to a table
  • Rename columns in a table
  • Modify the type of columns in a table
  • Re-order the columns in a table
  • Rename a table
  • Delete a table
  • Change the primary key of a table to another column containing unique values
  • Update the foreign key constraints on a table
  • Add an index (or unique index) to a column on a table
  • Drop an index from a table

Installation

Install this plugin in the same environment as Datasette.

pip install datasette-edit-schema

Usage

Navigate to /-/edit-schema/dbname/tablename on your Datasette instance to edit a specific table.

Use /-/edit-schema/dbname to create a new table in a specific database.

By default only the root actor can access the page - so you'll need to run Datasette with the --root option and click on the link shown in the terminal to sign in and access the page.

Permissions

The edit-schema permission governs access. You can use permission plugins such as datasette-permissions-sql to grant additional access to the write interface.

These permission checks will call the permission_allowed() plugin hook with three arguments:

  • action will be the string "edit-schema"
  • actor will be the currently authenticated actor - usually a dictionary
  • resource will be the string name of the database

Screenshot

datasette-edit-schema interface

Development

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

cd datasette-edit-schema
python3 -mvenv venv
source venv/bin/activate

Or if you are using pipenv:

pipenv shell

Now install the dependencies and tests:

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-edit-schema-0.7.tar.gz (67.7 kB view details)

Uploaded Source

Built Distribution

datasette_edit_schema-0.7-py3-none-any.whl (65.4 kB view details)

Uploaded Python 3

File details

Details for the file datasette-edit-schema-0.7.tar.gz.

File metadata

  • Download URL: datasette-edit-schema-0.7.tar.gz
  • Upload date:
  • Size: 67.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for datasette-edit-schema-0.7.tar.gz
Algorithm Hash digest
SHA256 4ba851628c3bb8283c4e2f6213b25d03dc08eb18c699f33da87a38e05a14a0bb
MD5 46b456a43fbad02a21a1829918609940
BLAKE2b-256 d7cabc0304ef29504c9dc0ad13ad5f70172e63500dafd243eb0ea20aacf79545

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for datasette_edit_schema-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 98da5d1bafe70240a6ceb70d199a9a7a889fd2fda5722e4e29977f9eaa9af853
MD5 62fe2acf324a4b84180b952b2874d6e1
BLAKE2b-256 23162b5dfa6e8984c0d861ca1599d4ea8c2ddd10c03cf12dde5a5034f14552cc

See more details on using hashes here.

Provenance

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