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
This commit is contained in:
Simon Willison 2017-11-13 11:33:01 -08:00
commit 8252e71da4
6 changed files with 76 additions and 25 deletions

View file

@ -80,17 +80,21 @@ http://localhost:8001/History/downloads.jsono will return that data as JSON in a
Serve up specified SQLite database files with a web UI
Options:
-h, --host TEXT host for server, defaults to 0.0.0.0
-p, --port INTEGER port for server, defaults to 8001
--debug Enable debug mode - useful for development
--reload Automatically reload if code change detected -
useful for development
--cors Enable CORS by serving Access-Control-Allow-Origin:
*
--inspect-file TEXT Path to JSON file created using "datasette build"
-m, --metadata FILENAME Path to JSON file containing license/source
metadata
--help Show this message and exit.
-h, --host TEXT host for server, defaults to 0.0.0.0
-p, --port INTEGER port for server, defaults to 8001
--debug Enable debug mode - useful for development
--reload Automatically reload if code change detected -
useful for development
--cors Enable CORS by serving Access-Control-Allow-
Origin: *
--page_size INTEGER Page size - default is 100
--max_returned_rows INTEGER Max allowed rows to return at once - default is
1000. Set to 0 to disable check entirely.
--inspect-file TEXT Path to JSON file created using "datasette
build"
-m, --metadata FILENAME Path to JSON file containing license/source
metadata
--help Show this message and exit.
## metadata.json