Commit graph

2,470 commits

Author SHA1 Message Date
Simon Willison
7fe1e8b482 Added extra metadata options to publish and package commands
You can now run these commands like so:

    datasette now publish mydb.db \
        --title="My Title" \
        --source="Source" \
        --source_url="http://www.example.com/" \
        --license="CC0" \
        --license_url="https://creativecommons.org/publicdomain/zero/1.0/"

This will write those values into the metadata.json that is packaged with the
app. If you also pass --metadata= that file will be updated with the extra
values before being written into the Docker image.

Closes #92
2017-11-14 21:02:11 -08:00
Andrew Cutler
86755503d2 Initial add simple prod ready Dockerfile refs #57 (#94) 2017-11-14 19:08:04 -08:00
Simon Willison
9cb69cbd45 New ?_sql_time_limit_ms=10 argument to database and table page
Allows callers to opt for a lower time limit.

Closes #95
2017-11-14 18:55:10 -08:00
Simon Willison
0b8c1b0a6d Test for sql_time_limit_ms + sqlite_functions mechanism
Added a unit test for the sql_time_limit_ms option.

To test this, I needed to add a custom SQLite sleep() function. I've added a
simple mechanism to the Datasette class for registering custom functions.

I also had to modify the sqlite_timelimit() function. It makes use of a magic
value, N, which is the number of SQLite virtual machine instructions that
should execute in between calls to my termination decision function.

The value of N was not finely grained enough for my test to work - so I've
added logic that says that if the time limit is less than 50ms, N is set to 1.
This got the tests working.

Refs #95
2017-11-14 18:43:34 -08:00
Simon Willison
4f7281af8c Apply a default height to CodeMirror
Makes it a bit more obvious that it's an editable textarea even
if the SQL in it is only one line long.
2017-11-14 18:04:04 -08:00
Simon Willison
cbb59e3801 Handle tables with names that start with digits 2017-11-14 18:03:21 -08:00
Tom Dyson
8252daa4c1 SQL syntax highlighting with Codemirror (#89) 2017-11-14 18:03:00 -08:00
Simon Willison
075d422c0a
Fixed typo 2017-11-13 21:28:02 -08:00
Simon Willison
98ae6d6a40
Added link to examples 2017-11-13 21:27:21 -08:00
Simon Willison
b0f3d4e375 Version 0.11 0.11 2017-11-13 17:48:22 -08:00
Simon Willison
fc7c04fe0b Added 'datasette publish now --force' option
This calls now with --force - which is useful as it means you get a fresh copy of
datasette even if now has already cached that docker layer.
2017-11-13 17:48:03 -08:00
Simon Willison
00527e5c62 Enable --cors by default in containers 2017-11-13 17:23:22 -08:00
Simon Willison
5928c11ee7 Version 0.10 0.10 2017-11-13 16:45:23 -08:00
Simon Willison
50e817801f Fixed #83
Turns out we had a redirect bug as well.
2017-11-13 16:44:43 -08:00
Simon Willison
bdfb6d4f13
Fixed package output example 2017-11-13 14:18:44 -08:00
Jeff Triplett
06a826c318 🔥 Removes DS_Store (#81)
* 🔥 Removes .DS_Store

Signed-off-by: Jeff Triplett <jeff.triplett@gmail.com>

* ❄️ Adds .DS_Store to gitignore

Signed-off-by: Jeff Triplett <jeff.triplett@gmail.com>
2017-11-13 14:16:54 -08:00
Simon Willison
44a199a062 Stop using sqlite WITH RECURSIVE in our tests
The version of Python 3 running in Travis CI doesn't support this.
2017-11-13 14:15:21 -08:00
Simon Willison
d75f423b6f Release 0.9 0.9 2017-11-13 14:00:53 -08:00
Simon Willison
1e698787a4 Added --sql_time_limit_ms and --extra-options
The serve command now accepts --sql_time_limit_ms for customizing the SQL time
limit.

The publish and package commands now accept --extra-options which can be used
to specify additional options to be passed to the datasite serve command when
it executes inside the rusulting Docker containers.
2017-11-13 14:00:53 -08:00
Simon Willison
452c5f047e
Added Travis CI badge to README
Closes #77
2017-11-13 13:24:14 -08:00
Simon Willison
fe279ab7b4 v0.8 - added PyPI metadata, ready to ship 0.8 2017-11-13 13:17:34 -08:00
Simon Willison
847f3e0c92 Implemented offset/limit pagination for views
Closes #70
2017-11-13 13:10:55 -08:00
Simon Willison
7dac1c05cd Improved pagination
Closes #78
2017-11-13 12:34:56 -08:00
Simon Willison
d76412668f Removed rogue middot 2017-11-13 12:34:39 -08:00
Simon Willison
79216bac12 Added some breathing room to the footer 2017-11-13 11:38:20 -08:00
Simon Willison
8252e71da4 Limit on max rows returned, controlled by --max_returned_rows option
If someone executes 'select * from table' against a table with a million rows
in it, we could run into problems: just serializing that much data as JSON is
likely to lock up the server.

Solution: we now have a hard limit on the maximum number of rows that can be
returned by a query. If that limit is exceeded, the server will return a
`"truncated": true` field in the JSON.

This limit can be optionally controlled by the new `--max_returned_rows`
option. Setting that option to 0 disables the limit entirely.

Closes #69
2017-11-13 11:33:01 -08:00
Simon Willison
6b3b05b6db Released 0.7 0.7 2017-11-13 10:42:30 -08:00
Simon Willison
e838bd743d Added README and improved help for 'datasette serve' 2017-11-13 10:41:59 -08:00
Simon Willison
20d41c8e8e publish now takes a required publisher argument - only current option is 'now'
Closes #76
2017-11-13 10:40:51 -08:00
Simon Willison
4fec50597a Include license/source in JSON output if provided 2017-11-13 10:39:25 -08:00
Simon Willison
97c4bf4271 Added --cors argument to enable CORS
Closes #75
2017-11-13 10:17:42 -08:00
Simon Willison
495407acef Force initial .inspect() before starting server
Otherwise there is a long pause on the first request made.
2017-11-13 10:03:52 -08:00
Simon Willison
4143e3b45c New command: datasette package - packages a docker container
Example usage:

    datasette package fivethirtyeight.db \
        --tag fivethirtyeight \
        --metadata=538-metadata.json

This will create a temporary directory, generate a Dockerfile, copy in the
SQLite database and metadata file, then build that as a new docker image and
tag that in your local Docker repository as fivethirtyeight:latest.

You can then run the image like so:

    docker run -p 8006:8001 fivethirtyeight

This will expose port 8001 in the container (the default) as port 8006 on your
host.

Closes #67
2017-11-13 08:17:35 -08:00
Simon Willison
3ef35ca8b4 serve and publish commands now take a --metadata option
If provided, the --metadata option is the path to a JSON file containing
metadata that should be displayed alongside the dataset.

    datasette /tmp/fivethirtyeight.db --metadata /tmp/metadata.json

Currently that metadata format looks like this:

    {
        "title": "Five Thirty Eight",
        "license": "CC Attribution 4.0 License",
        "license_url": "http://creativecommons.org/licenses/by/4.0/",
        "source": "fivethirtyeight/data on GitHub",
        "source_url": "https://github.com/fivethirtyeight/data"
    }

If provided, this will be used by the index template and to populate the
common footer.

The publish command also accepts this argument, and will package any provided
metadata up and include it with the resulting Docker container.

    datasette publish --metadata /tmp/metadata.json /tmp/fivethirtyeight.db

Closes #68
2017-11-13 07:20:02 -08:00
Simon Willison
ff2fb573cd datasette publish --name=now-accepts-name
Fixes #72
2017-11-12 18:12:21 -08:00
Simon Willison
2bbe9ca34a Support OPTIONS requests for CORS 2017-11-12 18:11:52 -08:00
Simon Willison
d01370f166 Show SQL and params if table has them applied 2017-11-12 15:21:39 -08:00
Simon Willison
26370b14d8 Handle table names with slashes in them
e.g. https://datasette-wdlexdiaoz.now.sh/fivethirtyeight-75d605c/bob-ross%2Felements-by-episode.csv?CABIN=1&BUSHES=1&CLOUDS=1
2017-11-12 15:17:00 -08:00
Simon Willison
4c66097d58 datasette publish now works with full paths
e.g. datasette publish /tmp/blah/database.db now does the right thing
2017-11-12 15:16:24 -08:00
Simon Willison
efecae5a11 Full path to database now works
e.g. datasette /tmp/blah.db

Previously this failed because it did not open with full path.
2017-11-12 15:01:29 -08:00
Simon Willison
db3fa4abfa Views no longer attempt to link to records
Closes #54
2017-11-12 13:29:26 -08:00
Simon Willison
59a616ca5c Move view SQL to bottom of the page
Now consistent with tables
2017-11-12 13:25:34 -08:00
Simon Willison
22851ed9f0 Table page now shows CREATE TABLE at bottom
Closes #66
2017-11-12 13:16:59 -08:00
Simon Willison
666aa03253 Improved error handling
Invalid SQL now shows a special error.html template, and is covered by tests.
2017-11-12 13:16:15 -08:00
Simon Willison
ff2ab9dc7d Views now show their SQL, are handled a bit better
Refs #66
2017-11-12 12:32:25 -08:00
Simon Willison
f4794df070 Added border-right to table cells 2017-11-12 12:19:18 -08:00
Simon Willison
8acdc2fd14 Test for table with space in name
Tests code in b51836f846
2017-11-12 12:08:32 -08:00
Simon Willison
b51836f846 Fixed bug with tables with spaces in their name
The new database index page was erroring.
2017-11-12 12:02:45 -08:00
Simon Willison
59580d02da Implemented custom SQL via textarea
Closes #65
2017-11-11 18:35:35 -08:00
Simon Willison
fd3a33989a Implemented new database view and template
Closes #53 - see comments there for screenshots.
2017-11-11 17:50:21 -08:00