Commit graph

663 commits

Author SHA1 Message Date
Simon Willison
bade9daeb2 Docs for 'datasette publish cloudrun', refs #434 2019-05-03 12:16:58 -04:00
Romain Primet
75a21fc2a1 datasette publish cloudrun (#434) - thanks, @rprimet
New publish subcommand that publishes using the
new Google Cloud Run platform.

    datasette publish cloudrun database.db
2019-05-03 09:59:01 -04:00
Russ Garrett
bf229c9bd8 Pass view_name to extra_body_script hook (#443)
At the moment it's not easy to tell whether the hook is being called
in (for example) the row or table view, as in both cases the
`database` and `table` parameters are provided.

This passes the `view_name` added in #441 to the `extra_body_script`
hook.
2019-05-03 09:12:19 -04:00
Russ Garrett
470cf0b05d Add a max-line-length setting for flake8 (#444)
This stops my automatic editor linting from flagging lines which are too
long. It's been lingering in my checkout for ages.

160 is an arbitrary large number - we could alter it if we have any
opinions (but I find the line length limit to be my least favourite part
of PEP8).
2019-05-03 09:11:27 -04:00
Simon Willison
53d2f00b73 Implemented ArrayFacet, closes #359 2019-05-02 20:21:27 -04:00
Simon Willison
ea66c45df9
Extract facet code out into a new plugin hook, closes #427 (#445)
Datasette previously only supported one type of faceting: exact column value counting.

With this change, faceting logic is extracted out into one or more separate classes which can implement other patterns of faceting - this is discussed in #427, but potential upcoming facet types include facet-by-date, facet-by-JSON-array, facet-by-many-2-many and more.

A new plugin hook, register_facet_classes, can be used by plugins to add in additional facet classes.

Each class must implement two methods: suggest(), which scans columns in the table to decide if they might be worth suggesting for faceting, and facet_results(), which executes the facet operation and returns results ready to be displayed in the UI.
2019-05-02 17:11:26 -07:00
Simon Willison
efc93b8ab5 Entirely removed table_rows_count table property
We were not displaying this anywhere, and it is now expensive to calculate.

Refs #419, #420
2019-05-01 22:29:47 -07:00
Simon Willison
3651eedf20 Show 'many rows' if count times out, refs #420 2019-05-01 22:20:24 -07:00
Simon Willison
ad9de774f7 Added missing file, refs #438 2019-05-01 22:10:23 -07:00
Simon Willison
f553a67021 Don't load setuptools plugins during test runs
Uses pattern from https://docs.pytest.org/en/latest/example/simple.html#detect-if-running-from-within-a-pytest-run

Closes #438
2019-05-01 22:09:03 -07:00
Simon Willison
033cf0bcbb DatabaseView no longer uses .inspect(), closes #420 2019-05-01 18:13:26 -07:00
Simon Willison
50d2d1aac9 Fixed bug where metadata.json hidden tables were ignored 2019-05-01 17:54:48 -07:00
Simon Willison
e7151ccccf Index page no longer uses inspect data - refs #420
Also introduced a mechanism whereby table counts are calculated against a time limit
but immutable databases have their table counts calculated on server startup.
2019-05-01 17:39:39 -07:00
Simon Willison
669fa21a71 Include request duration in traces 2019-05-01 16:27:14 -07:00
Russ Garrett
cf406c0754 New plugin hook: register_output_renderer hook (#441)
Thanks @russss!

* Add register_output_renderer hook

This changeset refactors out the JSON renderer and then adds a hook and
dispatcher system to allow custom output renderers to be registered.

The CSV output renderer is untouched because supporting streaming
renderers through this system would be significantly more complex, and
probably not worthwhile.

We can't simply allow hooks to be called at request time because we need
a list of supported file extensions when the request is being routed in
order to resolve ambiguous database/table names. So, renderers need to
be registered at startup.

I've tried to make this API independent of Sanic's request/response
objects so that this can remain stable during the switch to ASGI. I'm
using dictionaries to keep it simple and to make adding additional
options in the future easy.

Fixes #440
2019-05-01 16:01:56 -07:00
Simon Willison
bac4e01f40 Ensure sqlite_timelimit correctly clears handler
If an error occurred inside the block the progress handler (used to
enforce a time limit) was not being correctly cleared, resulting in
timeout errors potentially occurring during subsequent SQL queries.

The fix is described here: https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager
2019-04-21 12:02:24 -07:00
Simon Willison
11b352b4d5 Fix for Python 3.5, refs #435 2019-04-21 11:20:20 -07:00
Simon Willison
9d73e3c8bd Note that trace data format is very likely to change, refs #435 2019-04-21 10:53:28 -07:00
Simon Willison
e4e73a537a Test for ?_trace=1, refs #435 2019-04-21 10:46:56 -07:00
Simon Willison
58a862cee4 ?_trace=1 now adds SQL trace info to JSON/HTML response
Also added documentation for it. Refs #435
2019-04-21 10:41:16 -07:00
Simon Willison
7d01ca34a1 Added ?_trace=1 option to trace SQL
Currently just dumps all SQL statements out on the console.
2019-04-20 22:34:34 -07:00
Simon Willison
31f36e1b97
Added some guidelines
Mainly to remind me that master needs to be releasable at all times!
2019-04-20 11:32:40 -07:00
Simon Willison
2b11948d7c New ConnectedDatabase.mtime_ns property
I plan to use this for some clever table count caching tricks
2019-04-20 10:50:45 -07:00
Simon Willison
9c77e6e355 Support multiple filters of the same type
Closes #288
2019-04-15 16:44:17 -07:00
Simon Willison
583b22aa28 New ?column__date=yyyy-mm-dd filter 2019-04-15 15:54:54 -07:00
Simon Willison
1c6649b19b New colname__in=x,y,z filter, closes #433 2019-04-15 15:43:22 -07:00
Simon Willison
2c19a27d15 Documentation for filters, plus new documentation unit test
https://simonwillison.net/2018/Jul/28/documentation-unit-tests/
2019-04-15 15:41:11 -07:00
Simon Willison
6da567dda9 Extract and refactor filters into filters.py
This will help in implementing __in as a filter, refs #433
2019-04-15 14:51:20 -07:00
Simon Willison
9dc7a1824b
Slightly more interesting example link 2019-04-13 15:49:07 -07:00
Simon Willison
d4bfb8461c Removed accidental extra default plugins module 2019-04-13 12:33:23 -07:00
Simon Willison
d1075b8259 Cleaned up pylint warnings 2019-04-13 12:20:10 -07:00
Simon Willison
13ee3c222f Moved BaseView.absolute_url() to Datasette 2019-04-13 12:16:05 -07:00
Simon Willison
274ef43bb7 Moved expand_foreign_keys() from TableView to Datasette 2019-04-13 11:48:00 -07:00
Simon Willison
f2c767c222 Fixed broken link in documentation 2019-04-12 18:57:43 -07:00
Simon Willison
bc6a9b4564
?_where= parameter on table views, closes #429
From pull request #430
2019-04-12 18:37:22 -07:00
Simon Willison
e11cb4c664 Persist show/hide state better, closes #425 2019-04-11 22:00:47 -07:00
Simon Willison
db74cf0144 ?_fts_table= and ?_fts_pk= arguments, closes #428 2019-04-11 21:21:17 -07:00
Simon Willison
9cd3b44277
Upgrade to Jinja2==2.10.1 (#426) 2019-04-10 16:13:30 -07:00
Simon Willison
78e45ead4d New ?tags__arraycontains=tag lookup against JSON fields
Part one of supporting facet-by-JSON-array, refs #359
2019-04-10 08:27:52 -07:00
Simon Willison
3a208a41d4 TableView.data() no longer uses .inspect, refs #420
BUT... it does a count(*) against the whole table which may take unbounded time.

Fixing this is part of #422
2019-04-06 20:47:10 -07:00
Simon Willison
36bd6558b0 expandable_columns() no longer uses inspect, refs #420 2019-04-06 20:46:08 -07:00
Simon Willison
db02311ebf foreign_key_tables no longer uses inspect, refs #420 2019-04-06 20:23:30 -07:00
Simon Willison
f23120a964 RowView.data() no longer uses inspect refs #420 2019-04-06 20:17:47 -07:00
Simon Willison
c882e9262f display_columns_and_rows() no longer uses inspect, refs #420 2019-04-06 20:11:08 -07:00
Simon Willison
53bf875483 expand_foreign_keys() no longer uses inspect, refs #420 2019-04-06 19:56:07 -07:00
Simon Willison
97331f3435 sortable_columns_for_table() no longer uses inspect()
Refs #420
2019-04-06 18:58:51 -07:00
Simon Willison
d8851e0011 Removed rogue print() 2019-04-06 18:54:51 -07:00
Simon Willison
468c6fd953 DatabaseDownload no longer uses .inspect(), refs #420 2019-03-31 19:04:17 -07:00
Simon Willison
29a3896fe1 .database_url(database) no longer needs inspect, refs #420 2019-03-31 16:55:38 -07:00
Simon Willison
7d0f668556 .resolve_db_name() and .execute() work without inspect
Refs #420
2019-03-31 16:51:52 -07:00