Commit graph

118 commits

Author SHA1 Message Date
Konstantin Baikov
8e18c79431
Use context manager instead of plain open (#1211)
Context manager with open closes the files after usage.

When the object is already a pathlib.Path i used read_text
write_text functions

In some cases pathlib.Path.open were used in context manager,
it is basically the same as builtin open.

Thanks, Konstantin Baikov!
2021-03-11 08:15:49 -08:00
Simon Willison
640ac7071b Better PRAGMA error message, closes #1185 2021-01-12 14:26:19 -08:00
Simon Willison
8e8fc5cee5 Applied Black 2021-01-11 13:34:38 -08:00
Simon Willison
649f48cd70 request.full_path property, closes #1184 2021-01-11 13:32:58 -08:00
Miroslav Šedivý
a882d67962
Modernize code to Python 3.6+ (#1158)
* Compact dict and set building
* Remove redundant parentheses
* Simplify chained conditions
* Change method name to lowercase
* Use triple double quotes for docstrings

Thanks, @eumiro!
2020-12-23 09:04:32 -08:00
Simon Willison
90eba4c3ca Prettier CREATE TABLE SQL for _internal 2020-12-22 15:55:43 -08:00
Simon Willison
270de6527b Foreign keys for _internal database
Refs #1099 - Datasette now uses compound foreign keys internally,
so it would be great to link them correctly.
2020-12-22 11:48:54 -08:00
Simon Willison
bc1f1e1ce8 Compound primary key for foreign_keys table in _internal 2020-12-22 11:04:29 -08:00
Simon Willison
810853c5f2 Use time.perf_counter() instead of time.time(), closes #1157 2020-12-21 13:49:14 -08:00
Simon Willison
dcdfb2c301 Rename _schemas to _internal, closes #1156 2020-12-21 11:48:06 -08:00
Simon Willison
ebc7aa287c In-memory _schemas database tracking schemas of attached tables, closes #1150 2020-12-18 14:34:05 -08:00
Abdussamet Koçak
705d1a1555
Fix startup error on windows (#1128)
Fixes https://github.com/simonw/datasette/issues/1094

This import isn't used at all, and causes error on startup on Windows.
2020-12-05 11:35:03 -08:00
Simon Willison
00185af74a Show pysqlite3 version on /-/versions, if installed - #1125 2020-12-03 14:08:50 -08:00
Simon Willison
ca6e8e53dc More helpful 404 messages, refs #1124 2020-12-03 11:05:12 -08:00
Simon Willison
63efcb35ce More tweaks to root_path handling, refs #1124 2020-12-03 11:02:53 -08:00
Simon Willison
6b4c55efea Fix for Amazon Linux static assets 404ing, refs #1124 2020-12-03 10:53:26 -08:00
Simon Willison
a45a3dff3e Fix for OPTIONS request against /db, closes #1100 2020-12-02 16:49:55 -08:00
Simon Willison
17cbbb1f7f
generated_columns table in fixtures.py, closes #1119 2020-11-30 16:28:02 -08:00
Simon Willison
461670a0b8
Support for generated columns
* Support for generated columns, closes #1116
* Show SQLite version in pytest report header
* Use table_info() if SQLite < 3.26.0
* Cache sqlite_version() rather than re-calculate every time
* Adjust test_database_page for SQLite 3.26.0 or higher
2020-11-30 13:29:57 -08:00
Simon Willison
dea3c508b3 Revert "Support for generated columns, closes #1116" - it failed CI
This reverts commit 37f87b5e52.
2020-11-30 12:09:32 -08:00
Simon Willison
37f87b5e52 Support for generated columns, closes #1116 2020-11-30 12:01:15 -08:00
Simon Willison
deb0be4ae5 Fix bug where compound foreign keys produced broken links, closes #1098 2020-11-29 11:30:17 -08:00
Simon Willison
e800ffcf7c
/usr/local/lib/mod_spatialite.so
Closes #1114
2020-11-29 09:37:43 -08:00
Simon Willison
37d18a5bce datasette publish cloudrun --apt-get-install, closes #1110 2020-11-24 19:05:35 -08:00
Simon Willison
33eadb8782 config.json is now settings.json, closes #1104 2020-11-24 12:37:29 -08:00
Simon Willison
30e64c8d3b
Use f-strings in place of .format()
Code transformed like so:

    pip install flynt
    flynt .
    black .
2020-11-15 15:24:22 -08:00
Simon Willison
a4ca26a265 Address PrefixedUrlString bug in #1075 2020-10-31 13:35:47 -07:00
Simon Willison
84bc7244c1 datasette.client now applies base_url, closes #1026 2020-10-31 12:29:42 -07:00
Simon Willison
7a67bc7a56 datasette.urls methods will not apply base_url prefix twice, refs #1026 2020-10-31 12:11:40 -07:00
Simon Willison
11eb1e026f datasette.urls.table(..., format="json"), closes #1035
Also improved tests for datasette.urls and added format= to some other methods
2020-10-31 11:16:28 -07:00
Simon Willison
178b7e8749 .csv now links to .blob downloads
Closes #1063, closes #1034
2020-10-29 15:47:32 -07:00
Simon Willison
78b3eeaad9
.blob output renderer
* _blob_hash= checking plus refactored to use new BadRequest class, refs #1050
* Replace BlobView with new .blob renderer, closes #1050
* .blob downloads on arbitrary queries, closes #1051
2020-10-29 15:01:38 -07:00
Simon Willison
c3aba4aa98 --cors for /name.db downloads, refs #1057 2020-10-27 13:39:57 -07:00
Simon Willison
f5dbe61a45 -o now opens to most relevant page, closes #976 2020-10-25 22:06:20 -07:00
Simon Willison
310c3a3e05 New datasette.urls URL builders, refs #904 2020-10-19 17:33:59 -07:00
Simon Willison
6aa5886379 --load-extension=spatialite shortcut, closes #1028 2020-10-19 15:37:43 -07:00
Simon Willison
8f97b9b58e
datasette.client internal requests mechanism
Closes #943

* Datasette now requires httpx>=0.15
* Support OPTIONS without 500, closes #1001
* Added internals tests for datasette.client methods
* Datasette's own test mechanism now uses httpx to simulate requests
* Tests simulate HTTP 1.1 now
* Added base_url in a bunch more places
* Mark some tests as xfail - will remove that when new httpx release ships: #1005
2020-10-09 09:11:24 -07:00
Simon Willison
5a184a5d21 Display column type in column action menu, closes #993
Also added new documented db.table_column_details() introspection method.
2020-10-05 17:32:10 -07:00
Simon Willison
5b8b8ae597 Handle \r\n correctly in CSS escapes, refs #980 2020-09-29 12:16:30 -07:00
Simon Willison
c11383e628 Fix rendering glitch with columns on mobile, closes #978 2020-09-28 15:42:50 -07:00
Simon Willison
432a3d675f sqlite3.enable_callback_tracebacks(True), closes #891 2020-09-15 14:59:17 -07:00
Simon Willison
72ac2fd32c JSON API for writable canned queries, closes #880 2020-09-14 14:23:18 -07:00
Simon Willison
896fce228f Canned query writes support JSON POST body, refs #880 2020-09-14 13:18:15 -07:00
Simon Willison
a648bb82ba Upgrade to Black 20.8b1, closes #958 2020-09-02 15:24:55 -07:00
Simon Willison
26b2922f17 await_me_maybe utility function 2020-09-02 15:21:12 -07:00
Simon Willison
e139a7619f
'datasette --get' option, closes #926
Also made a start on the datasette.utils.testing module, refs #898
2020-08-11 17:24:40 -07:00
fcatus
2d7fa8b905
Use None as a default arg (#901)
Thanks, @fcatus!

* Use None as a default arg
* Black formatting fix

Co-authored-by: Simon Willison <swillison@gmail.com>
2020-07-31 11:42:38 -07:00
Simon Willison
0748a65a22 Fixed content-disposition header on DB download, closes #909 2020-07-29 14:34:22 -07:00
Simon Willison
092874202c Improvements to allow block logic and debug tool
true and false allow block values are now supported, closes #906

Added a bunch of demo links to the documentation, refs #908
2020-07-24 17:04:06 -07:00
Simon Willison
213e6a8926 content-length for DB downloads, closes #905 2020-07-21 21:52:35 -07:00