Commit graph

34 commits

Author SHA1 Message Date
Jacob Kaplan-Moss
de42240afd Some bug fixes. 2017-11-21 10:51:58 -08:00
Jacob Kaplan-Moss
75450abbe8 Merge branch 'master' into publish-heroku 2017-11-21 10:19:42 -08:00
Simon Willison
0331666e34
?_search=x now works directly against fts virtual table
Closes #135
2017-11-19 22:18:07 -08:00
Simon Willison
b4e6211a97
Refactored filter logic and added human descriptions - refs #86 2017-11-19 22:03:24 -08:00
Simon Willison
386fb11d42
?_filter_column=col&_filter_op=op&_filter_value=value redirect
Part of implementing the filters UI (refs #86) - the following:

    /trees/Trees?_filter_column=SiteOrder&_filter_op=gt&_filter_value=2

Now redirects to this;

    /trees/Trees?SiteOrder__gt=2
2017-11-19 12:25:29 -08:00
Simon Willison
ddc808f387
Added --build=master option to datasette publish and package
The `datasette publish` and `datasette package` commands both now accept an
optional `--build` argument. If provided, this can be used to specify a branch
published to GitHub that should be built into the container.

This makes it easier to test code that has not yet been officially released to
PyPI, e.g.:

    datasette publish now mydb.db --branch=master
2017-11-19 10:20:17 -08:00
Simon Willison
eed6a0fe36
Implemented ?_search=XXX + UI if a FTS table is detected
Closes #131
2017-11-19 08:59:26 -08:00
Jacob Kaplan-Moss
54d58ef690 Merge branch 'master' into publish-heroku 2017-11-17 13:36:50 -08:00
Jacob Kaplan-Moss
6eb23d2143 Moved datasette build to a post_compile hook. 2017-11-17 12:09:01 -08:00
Simon Willison
0b702f3679 Fixed weird edge-case with foreign key detection
It turns out it is possible for a SQLite table to define a foreign key
relationship to a table that does not actually exist

We should still be able to handle these databases.
2017-11-17 08:18:26 -08:00
Simon Willison
45e502aace Added unit tests for inspect() foreign key detection
Used them to fix a bug with it.

Refs #85
2017-11-17 08:08:11 -08:00
Ray N
ed2b3f25be add support for ?field__isnull=1 (#107)
* add support for ?field__isnull=1

* Add unit test and conditional formatting for ?field__isnull
2017-11-17 05:29:22 -08:00
Simon Willison
a4af532a31 Include foreign key info in inspect() output
Refs #85
2017-11-15 17:34:32 -08:00
Jacob Kaplan-Moss
f48cb705d8 Initial cut at datasette publish heroku
Rather gross, but proves that it works.
2017-11-15 11:53:00 -08:00
Simon Willison
f45ca30f91 Fixed bug with datasette package --metadata
Closes #84
2017-11-14 21:18:29 -08:00
Simon Willison
ea183b2ae3 Default to 127.0.0.1 not 0.0.0.0
Closes #98
2017-11-14 21:08:46 -08:00
Simon Willison
7fe1e8b482 Added extra metadata options to publish and package commands
You can now run these commands like so:

    datasette now publish mydb.db \
        --title="My Title" \
        --source="Source" \
        --source_url="http://www.example.com/" \
        --license="CC0" \
        --license_url="https://creativecommons.org/publicdomain/zero/1.0/"

This will write those values into the metadata.json that is packaged with the
app. If you also pass --metadata= that file will be updated with the extra
values before being written into the Docker image.

Closes #92
2017-11-14 21:02:11 -08:00
Simon Willison
0b8c1b0a6d Test for sql_time_limit_ms + sqlite_functions mechanism
Added a unit test for the sql_time_limit_ms option.

To test this, I needed to add a custom SQLite sleep() function. I've added a
simple mechanism to the Datasette class for registering custom functions.

I also had to modify the sqlite_timelimit() function. It makes use of a magic
value, N, which is the number of SQLite virtual machine instructions that
should execute in between calls to my termination decision function.

The value of N was not finely grained enough for my test to work - so I've
added logic that says that if the time limit is less than 50ms, N is set to 1.
This got the tests working.

Refs #95
2017-11-14 18:43:34 -08:00
Simon Willison
cbb59e3801 Handle tables with names that start with digits 2017-11-14 18:03:21 -08:00
Simon Willison
00527e5c62 Enable --cors by default in containers 2017-11-13 17:23:22 -08:00
Simon Willison
1e698787a4 Added --sql_time_limit_ms and --extra-options
The serve command now accepts --sql_time_limit_ms for customizing the SQL time
limit.

The publish and package commands now accept --extra-options which can be used
to specify additional options to be passed to the datasite serve command when
it executes inside the rusulting Docker containers.
2017-11-13 14:00:53 -08:00
Simon Willison
fe279ab7b4 v0.8 - added PyPI metadata, ready to ship 2017-11-13 13:17:34 -08:00
Simon Willison
6b3b05b6db Released 0.7 2017-11-13 10:42:30 -08:00
Simon Willison
97c4bf4271 Added --cors argument to enable CORS
Closes #75
2017-11-13 10:17:42 -08:00
Simon Willison
4143e3b45c New command: datasette package - packages a docker container
Example usage:

    datasette package fivethirtyeight.db \
        --tag fivethirtyeight \
        --metadata=538-metadata.json

This will create a temporary directory, generate a Dockerfile, copy in the
SQLite database and metadata file, then build that as a new docker image and
tag that in your local Docker repository as fivethirtyeight:latest.

You can then run the image like so:

    docker run -p 8006:8001 fivethirtyeight

This will expose port 8001 in the container (the default) as port 8006 on your
host.

Closes #67
2017-11-13 08:17:35 -08:00
Simon Willison
3ef35ca8b4 serve and publish commands now take a --metadata option
If provided, the --metadata option is the path to a JSON file containing
metadata that should be displayed alongside the dataset.

    datasette /tmp/fivethirtyeight.db --metadata /tmp/metadata.json

Currently that metadata format looks like this:

    {
        "title": "Five Thirty Eight",
        "license": "CC Attribution 4.0 License",
        "license_url": "http://creativecommons.org/licenses/by/4.0/",
        "source": "fivethirtyeight/data on GitHub",
        "source_url": "https://github.com/fivethirtyeight/data"
    }

If provided, this will be used by the index template and to populate the
common footer.

The publish command also accepts this argument, and will package any provided
metadata up and include it with the resulting Docker container.

    datasette publish --metadata /tmp/metadata.json /tmp/fivethirtyeight.db

Closes #68
2017-11-13 07:20:02 -08:00
Simon Willison
2bbe9ca34a Support OPTIONS requests for CORS 2017-11-12 18:11:52 -08:00
Simon Willison
26370b14d8 Handle table names with slashes in them
e.g. https://datasette-wdlexdiaoz.now.sh/fivethirtyeight-75d605c/bob-ross%2Felements-by-episode.csv?CABIN=1&BUSHES=1&CLOUDS=1
2017-11-12 15:17:00 -08:00
Simon Willison
2366a016f2 Added links to .json and .jsono representations
Closes #62
2017-11-11 14:40:44 -08:00
Simon Willison
40a563ebac Reworked metadata building options
Building metadata is now optional. If you want to do it, do this:

    datasette build *.db --metadata=metadata.json

Then when you run the server you can tell it to read from metadata:

    datasette serve *.db --metadata=metadata.json

The Dockerfile generated by datasette publish now uses this mechanism.

Closes #60
2017-11-11 12:11:51 -08:00
Simon Willison
65e350ca2a Implemented 'datasette publish one.db two.db' command
Closes #26
2017-11-10 23:25:22 -08:00
Simon Willison
7d81083d40 Implemented responsive tables, removed bootstrap
No need for all of bootstrap since we only need to style a few elements.

Implemented responsive table pattern from here:
https://css-tricks.com/responsive-data-tables/

Refs #16
2017-11-10 21:55:50 -08:00
Simon Willison
21c9c04310 Implemented cursor-based pagination for table view
Closes #5
2017-11-10 12:41:14 -08:00
Simon Willison
a8a293cd71 Refactored util functions into new utils module 2017-11-10 11:25:54 -08:00