Skip to main content

Write Datasette canned queries as plain SQL files

Project description

datasette-query-files

PyPI Changelog Tests License

Write Datasette canned queries as plain SQL files.

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-query-files

Or using pip or pipenv:

pip install datasette-query-files
pipenv install datasette-query-files

Usage

This plugin will look for canned queries in the filesystem, in addition any defined in metadata.

Let's say you're working in a directory called project-directory, with a database file called my-project.db. Start by creating a queries directory with a my-project directory inside it. Any SQL file inside that my-project folder will become a canned query that can be run on the my-project database. If you have a query-name.sql file and a query-name.json (or query-name.yml) file in the same directory, the JSON file will be used as query metadata.

project-directory/
  my-project.db
  queries/
    my-project/
      query-name.sql # a query
      query-name.yml # query metadata

Development

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

cd datasette-query-files
python3 -m venv venv
source venv/bin/activate

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-query-files-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

datasette_query_files-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file datasette-query-files-0.1.1.tar.gz.

File metadata

  • Download URL: datasette-query-files-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for datasette-query-files-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dfcd8880fb6b1126545a1fb21448e228963596ea877754527e7cb4edf95baad8
MD5 602069382b38676ec5e1166af133f454
BLAKE2b-256 72607b7e3466023744720fa446713dbb93a7987c778d77b5828796dd14484d63

See more details on using hashes here.

File details

Details for the file datasette_query_files-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_query_files-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6521e38682668f257bae09f78c02837f0a6158124c5cc10c0a125deb3d28676b
MD5 709d5671fdef29757ce5dcdb1e87fc82
BLAKE2b-256 af0731fb0cc38c202388c9d0076929e1ac7b9b3c2788e247248abdcbb4e74c52

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