datasette-write


Namedatasette-write JSON
Version 0.4 PyPI version JSON
download
home_pagehttps://github.com/simonw/datasette-write
SummaryDatasette plugin providing a UI for writing to a database
upload_time2024-09-04 04:50:16
maintainerNone
docs_urlNone
authorSimon Willison
requires_pythonNone
licenseApache License, Version 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # datasette-write

[![PyPI](https://img.shields.io/pypi/v/datasette-write.svg)](https://pypi.org/project/datasette-write/)
[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-write?label=changelog)](https://github.com/simonw/datasette-write/releases)
[![Tests](https://github.com/simonw/datasette-write/workflows/Test/badge.svg)](https://github.com/simonw/datasette-write/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-write/blob/master/LICENSE)

Datasette plugin providing a UI for writing to a database

## Installation

Install this plugin in the same environment as Datasette.
```bash
pip install datasette-write
```
## Usage

Having installed the plugin, visit `/db/-/write` on your Datasette instance to submit SQL queries that will be executed against a write connection to the specified database.

By default only the `root` user 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.

The `datasette-write` permission governs access. You can use permission plugins such as [datasette-permissions-sql](https://github.com/simonw/datasette-permissions-sql) to grant additional access to the write interface.

Pass `?sql=...` in the query string to pre-populate the SQL editor with a query.

## Parameterized queries

SQL queries can include parameters like this:
```sql
insert into news (title, body)
    values (:title, :body_textarea)
```
These will be converted into form fields on the `/db/-/write` page.

If a parameter name ends with `_textarea` it will be rendered as a multi-line textarea instead of a text input.

If a parameter name ends with `_hidden` it will be rendered as a hidden input.

## Updating rows with SQL

On Datasette 1.0a13 and higher a row actions menu item will be added to the row page linking to a SQL query for updating that row, for users with the `datasette-write` permission.

## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd datasette-write
python3 -mvenv venv
source venv/bin/activate
```
Or if you are using `pipenv`:
```bash
pipenv shell
```
Now install the dependencies and tests:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/simonw/datasette-write",
    "name": "datasette-write",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Simon Willison",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a2/29/52216a9a0d16c4f8e188436b7fb66c08af7a553a6379091b306f01ac8303/datasette_write-0.4.tar.gz",
    "platform": null,
    "description": "# datasette-write\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-write.svg)](https://pypi.org/project/datasette-write/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-write?label=changelog)](https://github.com/simonw/datasette-write/releases)\n[![Tests](https://github.com/simonw/datasette-write/workflows/Test/badge.svg)](https://github.com/simonw/datasette-write/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-write/blob/master/LICENSE)\n\nDatasette plugin providing a UI for writing to a database\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n```bash\npip install datasette-write\n```\n## Usage\n\nHaving installed the plugin, visit `/db/-/write` on your Datasette instance to submit SQL queries that will be executed against a write connection to the specified database.\n\nBy default only the `root` user 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.\n\nThe `datasette-write` permission governs access. You can use permission plugins such as [datasette-permissions-sql](https://github.com/simonw/datasette-permissions-sql) to grant additional access to the write interface.\n\nPass `?sql=...` in the query string to pre-populate the SQL editor with a query.\n\n## Parameterized queries\n\nSQL queries can include parameters like this:\n```sql\ninsert into news (title, body)\n    values (:title, :body_textarea)\n```\nThese will be converted into form fields on the `/db/-/write` page.\n\nIf a parameter name ends with `_textarea` it will be rendered as a multi-line textarea instead of a text input.\n\nIf a parameter name ends with `_hidden` it will be rendered as a hidden input.\n\n## Updating rows with SQL\n\nOn Datasette 1.0a13 and higher a row actions menu item will be added to the row page linking to a SQL query for updating that row, for users with the `datasette-write` permission.\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd datasette-write\npython3 -mvenv venv\nsource venv/bin/activate\n```\nOr if you are using `pipenv`:\n```bash\npipenv shell\n```\nNow install the dependencies and tests:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "Datasette plugin providing a UI for writing to a database",
    "version": "0.4",
    "project_urls": {
        "CI": "https://github.com/simonw/datasette-write/actions",
        "Changelog": "https://github.com/simonw/datasette-write/releases",
        "Homepage": "https://github.com/simonw/datasette-write",
        "Issues": "https://github.com/simonw/datasette-write/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ad12dc625b79d8d21ae1066f0a5060a6ea84c1ef8073bc1dd4d03003962cdea",
                "md5": "f043160c9261863ab89ee5777d47bdc0",
                "sha256": "810b55b65cc0383d406fa6cd14a0f642280700cacddf683505f58c14f1928849"
            },
            "downloads": -1,
            "filename": "datasette_write-0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f043160c9261863ab89ee5777d47bdc0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7503,
            "upload_time": "2024-09-04T04:50:15",
            "upload_time_iso_8601": "2024-09-04T04:50:15.736517Z",
            "url": "https://files.pythonhosted.org/packages/3a/d1/2dc625b79d8d21ae1066f0a5060a6ea84c1ef8073bc1dd4d03003962cdea/datasette_write-0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a22952216a9a0d16c4f8e188436b7fb66c08af7a553a6379091b306f01ac8303",
                "md5": "b3fa9c2fd75cc386d31dcd3910934d69",
                "sha256": "4b599b05950921b1bceb7a800583de9d7cf2b1071d642ba16fbb2df13d47f665"
            },
            "downloads": -1,
            "filename": "datasette_write-0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b3fa9c2fd75cc386d31dcd3910934d69",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9795,
            "upload_time": "2024-09-04T04:50:16",
            "upload_time_iso_8601": "2024-09-04T04:50:16.933983Z",
            "url": "https://files.pythonhosted.org/packages/a2/29/52216a9a0d16c4f8e188436b7fb66c08af7a553a6379091b306f01ac8303/datasette_write-0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-04 04:50:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "simonw",
    "github_project": "datasette-write",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "datasette-write"
}
        
Elapsed time: 0.39322s