Wykres commitów

227 Commity (b5b0b25d211aea32e5d1fe0aee9a955b2d20d053)

Autor SHA1 Wiadomość Data
Simon Willison b5b0b25d21 Try again 2019-05-11 14:58:39 -07:00
Simon Willison ebc3d92690 Extra debug info for Travis 2019-05-11 14:53:44 -07:00
Simon Willison a187c81e0c Black + fix broken test 2019-05-11 14:45:59 -07:00
Simon Willison c0d1b4c322 "datasette inspect foo.db" now just calculates table counts
Refs #462

* inspect command now just outputs table counts
* test_inspect.py is now only tests for that CLI command
* Updated some relevant documentation
* Removed docs for /-/inspect since that is about to change
2019-05-11 14:36:57 -07:00
Simon Willison ce09e5d2d3 Fixed tests relating to #459 2019-05-11 13:58:22 -07:00
Simon Willison 05cabaebd9 Pass --token to now alias, refs #459 2019-05-11 13:35:34 -07:00
Simon Willison 09ef305c68 Fixed "datasette publish now ... --alias=x"
The --alias argument can now be passed more than once.

Also updated our Travis configuration to use this.

Fixes #459
2019-05-11 13:20:36 -07:00
Simon Willison a0d444837f Finished implementation of ?_trace=1 debug tool
I redesigned the JSON output and added a handy "traceback" key showing
three relevant lines of the current traceback for each logged query.

Closes #435
2019-05-11 12:06:22 -07:00
Simon Willison 2db977d8f3 tests/fixtures.py can now write out plugins too
This command:

    python tests/fixtures.py \
        fixtures.db \
        metadata.json \
        fixtures-plugins/

Will now create the fixtures.db and metadata.json files, AND create
a folder called fixtures-plugins/ containing two test plugins.

You can then run it like this:

    datasette fixtures.db \
        -m metadata.json --plugins-dir=fixtures-plugins/
2019-05-09 09:44:21 -07:00
Simon Willison 9fdb47ca95 New encode/decode_path_component functions
ASGI cannot differentiate between / and %2F in a URL, so we need an
alternative scheme for encoding the names of tables that contain special
characters such as /

For background, see
    https://github.com/django/asgiref/issues/51#issuecomment-450603464

Some examples:

    "table/and/slashes" => "tableU+002FandU+002Fslashes"
    "~table" => "U+007Etable"
    "+bobcats!" => "U+002Bbobcats!"
    "U+007Etable" => "UU+002B007Etable"
2019-05-09 09:44:21 -07:00
Simon Willison ec2db345e9 Fixed crash on /:memory: page 2019-05-05 14:01:14 -04:00
Simon Willison 831515b834 Respect --cors for error pages, closes #453 2019-05-05 08:12:03 -04:00
Simon Willison 35d6ee2790
Apply black to everything, enforce via unit tests (#449)
I've run the black code formatting tool against everything:

    black tests datasette setup.py

I also added a new unit test, in tests/test_black.py, which will fail if the code does not
conform to black's exacting standards.

This unit test only runs on Python 3.6 or higher, because black itself doesn't run on 3.5.
2019-05-03 22:15:14 -04:00
Simon Willison 93c65d29ba Fixed 500 error on /-/metadata page 2019-05-03 16:42:59 -04:00
Simon Willison 01b3de5b66 Unit test for binary data display, refs #442 2019-05-03 12:45:06 -04:00
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
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 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 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 e4e73a537a Test for ?_trace=1, refs #435 2019-04-21 10:46:56 -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 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 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 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 468c6fd953 DatabaseDownload no longer uses .inspect(), refs #420 2019-03-31 19:04:17 -07:00
Simon Willison 7d0f668556 .resolve_db_name() and .execute() work without inspect
Refs #420
2019-03-31 16:51:52 -07:00
Simon Willison 0209a0a344 table_exists() now uses async SQL, refs #420 2019-03-31 11:02:22 -07:00
Simon Willison 6f6d0ff2b4
URL hashing is now off by default - closes #418
Prior to this commit Datasette would calculate the content hash of every
database and redirect to a URL containing that hash, like so:

    https://v0-27.datasette.io/fixtures => https://v0-27.datasette.io/fixtures-dd88475

This assumed that all databases were opened in immutable mode and were not
expected to change.

This will be changing as a result of #419 - so this commit takes the first step
in implementing that change by changing this default behaviour. Datasette will
now only redirect hash-free URLs under two circumstances:

* The new `hash_urls` config option is set to true (it defaults to false).
* The user passes `?_hash=1` in the URL
2019-03-17 15:55:04 -07:00
Simon Willison afe9aa3ae0 show/hide link for SQL on custom query page
Closes #415
2019-03-14 22:22:35 -07:00
Simon Willison 2855667908 Fix for test failure with Click 7.0 2019-03-14 22:00:13 -07:00
Simon Willison 9743e1d91b Support for :memory: databases
If you start Datasette with no files, it will connect to :memory: instead.

When starting it with files you can add --memory to also get a :memory: database.
2019-03-14 20:54:42 -07:00
Simon Willison bf6b0f918d about and about_url metadata options 2019-03-14 20:54:42 -07:00
Simon Willison 4462a5ab28 Show size of database file next to download link, closes #172 2019-02-05 20:58:29 -08:00
Simon Willison 195a5b3634
Heroku --include-vcs-ignore (#407)
Means `datasette publish heroku` can work under Travis, unlike this failure:

https://travis-ci.org/simonw/fivethirtyeight-datasette/builds/488047550

```
2.25s$ datasette publish heroku fivethirtyeight.db -m metadata.json -n fivethirtyeight-datasette
tar: unrecognized option '--exclude-vcs-ignores'
Try 'tar --help' or 'tar --usage' for more information.
 ▸    Command failed: tar cz -C /tmp/tmpuaxm7i8f --exclude-vcs-ignores --exclude
 ▸    .git --exclude .gitmodules . >
 ▸    /tmp/f49440e0-1bf3-4d3f-9eb0-fbc2967d1fd4.tar.gz
 ▸    tar: unrecognized option '--exclude-vcs-ignores'
 ▸    Try 'tar --help' or 'tar --usage' for more information.
 ▸    
The command "datasette publish heroku fivethirtyeight.db -m metadata.json -n fivethirtyeight-datasette" exited with 0.
```

The fix for that issue is to call the heroku command like this:

    heroku builds:create -a app_name --include-vcs-ignore
2019-02-05 20:15:46 -08:00
Simon Willison b5dd83981a Export option: _shape=array&_nl=on for newline-delimited JSON 2019-01-27 17:40:23 -08:00
Simon Willison c3a78eb05c app_client() fixture doesn't need to take **kwargs 2019-01-13 14:23:44 -08:00