mirror of
https://github.com/simonw/datasette.git
synced 2026-06-07 09:36:57 +02:00
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:
parent
6b3b05b6db
commit
8252e71da4
6 changed files with 76 additions and 25 deletions
|
|
@ -97,9 +97,11 @@ def package(files, tag, metadata):
|
|||
@click.option('--debug', is_flag=True, help='Enable debug mode - useful for development')
|
||||
@click.option('--reload', is_flag=True, help='Automatically reload if code change detected - useful for development')
|
||||
@click.option('--cors', is_flag=True, help='Enable CORS by serving Access-Control-Allow-Origin: *')
|
||||
@click.option('--page_size', default=100, help='Page size - default is 100')
|
||||
@click.option('--max_returned_rows', default=1000, help='Max allowed rows to return at once - default is 1000. Set to 0 to disable check entirely.')
|
||||
@click.option('--inspect-file', help='Path to JSON file created using "datasette build"')
|
||||
@click.option('-m', '--metadata', type=click.File(mode='r'), help='Path to JSON file containing license/source metadata')
|
||||
def serve(files, host, port, debug, reload, cors, inspect_file, metadata):
|
||||
def serve(files, host, port, debug, reload, cors, page_size, max_returned_rows, inspect_file, metadata):
|
||||
"""Serve up specified SQLite database files with a web UI"""
|
||||
if reload:
|
||||
import hupper
|
||||
|
|
@ -118,6 +120,8 @@ def serve(files, host, port, debug, reload, cors, inspect_file, metadata):
|
|||
files,
|
||||
cache_headers=not debug and not reload,
|
||||
cors=cors,
|
||||
page_size=page_size,
|
||||
max_returned_rows=max_returned_rows,
|
||||
inspect_data=inspect_data,
|
||||
metadata=metadata_data,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue