Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datasette fixtures.db --get "/fixtures.json" #926

simonw opened this issue Aug 11, 2020 · 2 comments

datasette fixtures.db --get "/fixtures.json" #926

simonw opened this issue Aug 11, 2020 · 2 comments


Copy link

simonw commented Aug 11, 2020

I can expose ALL of Datasette's functionality on the command-line (without even running a web server) by adding --get and --post options to datasette serve.

datasette fixtures.db --get "/fixtures.json"

This would instantiate the Datasette ASGI app, run a fake request for /fixtures.json through it, dump the results out to standard output and quit.

A --post option could do the same for a POST request. Treating that as a stretch goal for the moment.

Copy link
Owner Author

simonw commented Aug 11, 2020

I partly want this so I can easily implement a better test method for the Homebrew package. The test I have right now looks like this:

  test do
    system bin/"datasette", "--help"

The Homebrew docs at say:

We want tests that don't require any user input and test the basic functionality of the application. For example foo build-foo is a good test and (despite their widespread use) foo --version and foo --help are bad tests. However, a bad test is better than no test at all.

Copy link
Owner Author

simonw commented Aug 12, 2020

$ datasette --get '/:memory:.json?sql=select+sqlite_version()' | jq .
  "database": ":memory:",
  "query_name": null,
  "rows": [
  "truncated": false,
  "columns": [
  "query": {
    "sql": "select sqlite_version()",
    "params": {}
  "private": false,
  "allow_execute_sql": true,
  "query_ms": 1.165628433227539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant