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
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
Simon Willison
2366a016f2
Added links to .json and .jsono representations
...
Closes #62
2017-11-11 14:40:44 -08:00
Simon Willison
fa42a56c6a
Bulked out table test a bit
...
I'm closing #50 - more tests will be added in the future, but the framework
is neatly in place for them now.
2017-11-11 14:22:47 -08:00
Simon Willison
e9e1def4c0
Revised JSON design a bit
...
Closes #63
2017-11-11 14:20:00 -08:00
Simon Willison
e4bf66d9b0
Added header with breadcrumbs and footer
...
Also cleaned up titles on various pages.
Closes #61
2017-11-11 12:36:20 -08:00
Simon Willison
40a563ebac
Reworked metadata building options
...
Building metadata is now optional. If you want to do it, do this:
datasette build *.db --metadata=metadata.json
Then when you run the server you can tell it to read from metadata:
datasette serve *.db --metadata=metadata.json
The Dockerfile generated by datasette publish now uses this mechanism.
Closes #60
2017-11-11 12:11:51 -08:00
Simon Willison
ad8b5d3bd2
JSON version of our homepage
...
Now available at http://localhost:8006/.json
Tested by tests added in 407795b612
2017-11-11 09:49:47 -08:00
Simon Willison
407795b612
Initial unit tests against our Sanic app
...
Refs #50
I had to disable the build metadata function to get these tests to work
sensibly. I need to completely rethink how that mechanism works.
2017-11-11 09:47:59 -08:00
Simon Willison
3280972c89
Fixed tests I broke earlier
...
Broke these tests in 21c9c04310
2017-11-11 08:52:17 -08:00
Simon Willison
3863a30b5d
publish command checks 'now' is installed
...
Closes #58
2017-11-11 08:00:00 -08:00
Simon Willison
65e350ca2a
Implemented 'datasette publish one.db two.db' command
...
Closes #26
2017-11-10 23:25:22 -08:00
Simon Willison
7d81083d40
Implemented responsive tables, removed bootstrap
...
No need for all of bootstrap since we only need to style a few elements.
Implemented responsive table pattern from here:
https://css-tricks.com/responsive-data-tables/
Refs #16
2017-11-10 21:55:50 -08:00
Simon Willison
21c9c04310
Implemented cursor-based pagination for table view
...
Closes #5
2017-11-10 12:41:14 -08:00
Simon Willison
e9fce44195
Don't serve cache headers in debug or refresh modes
2017-11-10 12:26:37 -08:00
Simon Willison
a8a293cd71
Refactored util functions into new utils module
2017-11-10 11:25:54 -08:00
Simon Willison
1c57bd202f
Replaced app_factory with new Datasette class
...
This should make it easier to add unit tests.
2017-11-10 11:05:57 -08:00
Simon Willison
03c58fb350
Show databases in alphabetical order on index page
2017-11-10 11:04:56 -08:00
Simon Willison
40d3b3eae6
Refactored tests into new tests/ folder
...
Guided by https://docs.pytest.org/en/latest/goodpractices.html
2017-11-10 10:48:16 -08:00
Simon Willison
e06b011771
Updated tests
...
Refs #23
2017-11-10 10:43:54 -08:00
Simon Willison
e7e50875d3
Renamed to 'datasette'
2017-11-10 10:38:35 -08:00
Simon Willison
292f140a4f
Explicitly order by pk (or by rowid)
...
Refs #5
2017-11-09 08:11:14 -08:00
Simon Willison
bc9871c935
gt/lt/gte/lte now treat numeric arguments as numeric
...
This now works:
https://immutabase-dlmggyoepw.now.sh/northwind-40d049b/Products?UnitsInStock__gt=100
Previously the input value of 100 would be treated as a string.
Also fixed a bug where filter arguments had stopped working entirely.
Refs #23
2017-11-09 08:09:55 -08:00
Simon Willison
d9fa2bf7ba
Use rowid if no primary key available
...
Allows us to link to individual records even for tables that do not have a primary key.
Refs #5
2017-11-09 06:39:50 -08:00
Simon Willison
b2dee11fcd
Databases now get distinct colours
...
A left border based on their content hash.
Closes #31
2017-11-09 06:14:40 -08:00
Simon Willison
abb591d832
Added --reload argument to 'immutabase serve' command
...
Uses hupper to restart the server when the code changes. Useful for development.
Depends on https://pypi.python.org/pypi/hupper
2017-11-09 06:14:26 -08:00