Renamed --limit to --config, added --help-config, closes #274

Removed the --page_size= argument to datasette serve in favour of:

    datasette serve --config default_page_size:50 mydb.db

Added new help section:

    $ datasette --help-config
    Config options:
      default_page_size            Default page size for the table view
                                   (default=100)
      max_returned_rows            Maximum rows that can be returned from a table
                                   or custom query (default=1000)
      sql_time_limit_ms            Time limit for a SQL query in milliseconds
                                   (default=1000)
      default_facet_size           Number of values to return for requested facets
                                   (default=30)
      facet_time_limit_ms          Time limit for calculating a requested facet
                                   (default=200)
      facet_suggest_time_limit_ms  Time limit for calculating a suggested facet
                                   (default=50)
This commit is contained in:
Simon Willison 2018-05-20 10:01:49 -07:00
commit f6183ff5fa
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
10 changed files with 142 additions and 95 deletions

View file

@ -1,7 +1,17 @@
Limits
Config
======
To prevent rogue, long-running queries from making a Datasette instance inaccessible to other users, Datasette imposes some limits on the SQL that you can execute.
Datasette provides a number of configuration options. These can be set using the ``--config name:value`` option to ``datasette serve``.
To prevent rogue, long-running queries from making a Datasette instance inaccessible to other users, Datasette imposes some limits on the SQL that you can execute. These are exposed as config options which you can over-ride.
default_page_size
-----------------
The default number of rows returned by the table page. You can over-ride this on a per-page basis using the ``?_size=80`` querystring parameter, provided you do not specify a value higher than the ``max_returned_rows`` setting. You can set this default using ``--config`` like so::
datasette mydatabase.db --config default_page_size:50
sql_time_limit_ms
-----------------
@ -10,9 +20,9 @@ By default, queries have a time limit of one second. If a query takes longer tha
If this time limit is too short for you, you can customize it using the ``sql_time_limit_ms`` limit - for example, to increase it to 3.5 seconds::
datasette mydatabase.db --limit sql_time_limit_ms:3500
datasette mydatabase.db --config sql_time_limit_ms:3500
You can optionally set a lower time limit for an individual query using the ``_timelimit`` query string argument::
You can optionally set a lower time limit for an individual query using the ``?_timelimit=100`` query string argument::
/my-database/my-table?qSpecies=44&_timelimit=100
@ -25,21 +35,21 @@ Datasette returns a maximum of 1,000 rows of data at a time. If you execute a qu
You can increase or decrease this limit like so::
datasette mydatabase.db --limit max_returned_rows:2000
datasette mydatabase.db --config max_returned_rows:2000
default_facet_size
------------------
The default number of unique rows returned by :ref:`facets` is 30. You can customize it like this::
datasette mydatabase.db --limit default_facet_size:50
datasette mydatabase.db --config default_facet_size:50
facet_time_limit_ms
-------------------
This is the time limit Datasette allows for calculating a facet, which defaults to 200ms::
datasette mydatabase.db --limit facet_time_limit_ms:1000
datasette mydatabase.db --config facet_time_limit_ms:1000
facet_suggest_time_limit_ms
---------------------------
@ -48,4 +58,4 @@ When Datasette calculates suggested facets it needs to run a SQL query for every
You can increase this time limit like so::
datasette mydatabase.db --limit facet_suggest_time_limit_ms:500
datasette mydatabase.db --config facet_suggest_time_limit_ms:500

View file

@ -100,7 +100,6 @@ datasette serve options
useful for development
--cors Enable CORS by serving Access-Control-Allow-
Origin: *
--page_size INTEGER Page size - default is 100
--load-extension PATH Path to a SQLite extension to load
--inspect-file TEXT Path to JSON file created using "datasette
inspect"
@ -110,6 +109,7 @@ datasette serve options
--plugins-dir DIRECTORY Path to directory containing custom plugins
--static STATIC MOUNT mountpoint:path-to-directory for serving static
files
--limit LIMIT Set a limit using limitname:integer
datasette.readthedocs.io/en/latest/limits.html
--config CONFIG Set config option using configname:value
datasette.readthedocs.io/en/latest/config.html
--help-config Show available config options
--help Show this message and exit.

View file

@ -22,7 +22,7 @@ Contents
facets
full_text_search
metadata
limits
config
custom_templates
plugins
changelog