home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

37 rows where "updated_at" is on date 2022-03-19 sorted by updated_at descending

✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: issue_url, created_at (date), updated_at (date)

issue 12

  • Introduce concept of a database `route`, separate from its name 15
  • 500 error caused by faceting if a column called `n` exists 5
  • Remove hashed URL mode 3
  • Refactor URL routing to enable testing 3
  • Make route matched pattern groups more consistent 3
  • Remove Hashed URL mode 2
  • New pattern for views that return either JSON or HTML, available for plugins 1
  • UNIQUE constraint failed: workouts.id 1
  • add hash id to "_memory" url if hashed url mode is turned on and crossdb is also turned on 1
  • Scripted exports 1
  • Refactor and simplify Datasette routing and views 1
  • [feature request] Publish to fully static website 1

user 3

  • simonw 35
  • lchski 1
  • Kabouik 1

author_association 2

  • OWNER 35
  • NONE 2
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1073126264 https://github.com/simonw/datasette/issues/1668#issuecomment-1073126264 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9pt4 simonw 9599 2022-03-19T22:59:30Z 2022-03-19T22:59:30Z OWNER

Also need to update the datasette.urls methods that construct the URL to a database/table/row - they take the database name but they need to know to look for the route.

Need to add tests that check the links in the HTML and can confirm this is working correctly.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073125334 https://github.com/simonw/datasette/issues/1668#issuecomment-1073125334 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9pfW simonw 9599 2022-03-19T22:53:55Z 2022-03-19T22:53:55Z OWNER

Need to update documentation in a few places - e.g. https://docs.datasette.io/en/stable/internals.html#remove-database-name

This removes a database that has been previously added. name= is the unique name of that database, used in its URL path.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073123231 https://github.com/dogsheep/healthkit-to-sqlite/issues/14#issuecomment-1073123231 https://api.github.com/repos/dogsheep/healthkit-to-sqlite/issues/14 IC_kwDOC8tyDs4_9o-f lchski 343884 2022-03-19T22:39:29Z 2022-03-19T22:39:29Z NONE

I have this issue, too, with a fresh export. None of my Workout entries in export.xml have an id key, though the sample export.xml in the tests folder doesn’t either, so I don’t think this is the culprit. Indeed, it seems @simonw is using the hash_id function from sqlite_utils, which creates a column (id, in this case) based on a hash of the row’s contents.

When I run the script, a workouts table is created, with one entry: my first workout. No workout_points table is created, as I’d expect from utils.py. I then get essentially the same error as noted in this thread:

Importing from HealthKit [###################################-] 98% 00:00:01 Traceback (most recent call last): File "/Users/lchski/.pyenv/versions/3.10.3/bin/healthkit-to-sqlite", line 8, in <module> sys.exit(cli()) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/healthkit_to_sqlite/cli.py", line 57, in cli convert_xml_to_sqlite(fp, db, progress_callback=bar.update, zipfile=zf) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/healthkit_to_sqlite/utils.py", line 34, in convert_xml_to_sqlite workout_to_db(el, db, zipfile) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/healthkit_to_sqlite/utils.py", line 57, in workout_to_db pk = db["workouts"].insert(record, alter=True, hash_id="id").last_pk File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/sqlite_utils/db.py", line 2822, in insert return self.insert_all( File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/sqlite_utils/db.py", line 2950, in insert_all self.insert_chunk( File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/sqlite_utils/db.py", line 2715, in insert_chunk result = self.db.execute(query, params) File "/Users/lchski/.pyenv/versions/3.10.3/lib/python3.10/site-packages/sqlite_utils/db.py", line 458, in execute return self.conn.execute(sql, parameters) sqlite3.IntegrityError: UNIQUE constraint failed: workouts.id

Are there maybe duplicate workouts in the data, which’d cause multiple rows to share the same id? It’s strange, though, that no workout_points is created at all. Export created from iOS 15.3.1.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
UNIQUE constraint failed: workouts.id 771608692  
1073112104 https://github.com/simonw/datasette/issues/1668#issuecomment-1073112104 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9mQo simonw 9599 2022-03-19T21:08:21Z 2022-03-19T21:08:21Z OWNER

I think I've got this working but I need to write a test for it that covers the rare case when the route is not the same thing as the database name.

I'll do that with a new test.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073097394 https://github.com/simonw/datasette/issues/1668#issuecomment-1073097394 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9iqy simonw 9599 2022-03-19T20:56:35Z 2022-03-19T20:56:35Z OWNER

I'm trying to think if there's any reason not to use route for this. Would I possibly want to use that noun for something else in the future? I like it more than route_path because it has no underscore.

Decision made: I'm going with route.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073076624 https://github.com/simonw/datasette/issues/1667#issuecomment-1073076624 https://api.github.com/repos/simonw/datasette/issues/1667 IC_kwDOBm6k_c4_9dmQ simonw 9599 2022-03-19T20:31:44Z 2022-03-19T20:31:44Z OWNER

I can now read format from request.url_vars and delete this code entirely: https://github.com/simonw/datasette/blob/b9c2b1cfc8692b9700416db98721fa3ec982f6be/datasette/views/base.py#L375-L381

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make route matched pattern groups more consistent 1174302994  
1073076187 https://github.com/simonw/datasette/issues/1668#issuecomment-1073076187 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9dfb simonw 9599 2022-03-19T20:28:20Z 2022-03-19T20:28:20Z OWNER

I'm going to keep path as the path to the file on disk. I'll pick a new name for what is currently path in that undocumented JSON API.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073076136 https://github.com/simonw/datasette/issues/1668#issuecomment-1073076136 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9deo simonw 9599 2022-03-19T20:27:44Z 2022-03-19T20:27:44Z OWNER

Pretty sure changing it will break some existing plugins though, including likely Datasette Desktop.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073076110 https://github.com/simonw/datasette/issues/1668#issuecomment-1073076110 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9deO simonw 9599 2022-03-19T20:27:22Z 2022-03-19T20:27:22Z OWNER

The docs do currently describe path as the filesystem path here: https://docs.datasette.io/en/stable/internals.html#database-class

Good thing I'm not at 1.0 yet so I can change that!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073076015 https://github.com/simonw/datasette/issues/1668#issuecomment-1073076015 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9dcv simonw 9599 2022-03-19T20:26:32Z 2022-03-19T20:26:32Z OWNER

I'm inclined to redefine ds.path to ds.file_path to fix this. Or ds.filepath.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073075913 https://github.com/simonw/datasette/issues/1668#issuecomment-1073075913 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9dbJ simonw 9599 2022-03-19T20:25:46Z 2022-03-19T20:26:08Z OWNER

The output of /.json DOES use path to mean the URL path, not the path to the file on disk:

{ "fixtures.dot": { "name": "fixtures.dot", "hash": null, "color": "631f11", "path": "/fixtures~2Edot", So that's a problem already: having db.path refer to something different from that JSON is inconsistent.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073075697 https://github.com/simonw/datasette/issues/1668#issuecomment-1073075697 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9dXx simonw 9599 2022-03-19T20:24:06Z 2022-03-19T20:24:06Z OWNER

Right now if a database has a . in its name e.g. fixtures.dot the URL to that database is:

/fixtures~2Edot

But the output on /-/databases doesn't reflect that, it still shows the name with the dot.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073073599 https://github.com/simonw/datasette/issues/1660#issuecomment-1073073599 https://api.github.com/repos/simonw/datasette/issues/1660 IC_kwDOBm6k_c4_9c2_ simonw 9599 2022-03-19T20:06:40Z 2022-03-19T20:06:40Z OWNER

This blocks: - #1668

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Refactor and simplify Datasette routing and views 1170144879  
1073073579 https://github.com/simonw/datasette/issues/1668#issuecomment-1073073579 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9c2r simonw 9599 2022-03-19T20:06:27Z 2022-03-19T20:06:27Z OWNER

Marking this as blocked until #1660 is done.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073073547 https://github.com/simonw/datasette/issues/1668#issuecomment-1073073547 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9c2L simonw 9599 2022-03-19T20:06:07Z 2022-03-19T20:06:07Z OWNER

Implementing this is a little tricky because there's a whole lot of code that expects the database captured by the URL routing to be the name used to look up the database in datasette.databases - or via .get_database().

The DataView.get() method is a good example of the trickyness here. It even has code that dispatches out to plugin hooks that take database as a parameter.

https://github.com/simonw/datasette/blob/61419388c134001118aaf7dfb913562d467d7913/datasette/views/base.py#L383-L555

All the more reason to get rid of that BaseView -> DataView -> TableView hierarchy entirely: - #1660

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073043433 https://github.com/simonw/datasette/issues/1668#issuecomment-1073043433 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9Vfp simonw 9599 2022-03-19T16:54:55Z 2022-03-19T20:01:19Z OWNER

Options: - route_path - url_path - route

I like route_path, or maybe route.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073043713 https://github.com/simonw/datasette/issues/1668#issuecomment-1073043713 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9VkB simonw 9599 2022-03-19T16:56:19Z 2022-03-19T16:56:19Z OWNER

Worth noting that the name right now is picked automatically to avoid conflicts:

https://github.com/simonw/datasette/blob/61419388c134001118aaf7dfb913562d467d7913/datasette/app.py#L397-L413

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073043350 https://github.com/simonw/datasette/issues/1668#issuecomment-1073043350 https://api.github.com/repos/simonw/datasette/issues/1668 IC_kwDOBm6k_c4_9VeW simonw 9599 2022-03-19T16:54:26Z 2022-03-19T16:54:26Z OWNER

The Database class already has a path property but it means something else - it's the path to the .db file on disk:

https://github.com/simonw/datasette/blob/61419388c134001118aaf7dfb913562d467d7913/datasette/database.py#L29-L50

So need a different name for the path-that-is-used-in-the-URL.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Introduce concept of a database `route`, separate from its name 1174306154  
1073042554 https://github.com/simonw/datasette/issues/1667#issuecomment-1073042554 https://api.github.com/repos/simonw/datasette/issues/1667 IC_kwDOBm6k_c4_9VR6 simonw 9599 2022-03-19T16:50:01Z 2022-03-19T16:52:35Z OWNER

OK, I've made this more consistent - I still need to address the fact that format can be .json or json or not used at all before I close this issue.

https://github.com/simonw/datasette/blob/61419388c134001118aaf7dfb913562d467d7913/tests/test_routes.py#L15-L35

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make route matched pattern groups more consistent 1174302994  
1073040072 https://github.com/simonw/datasette/issues/1667#issuecomment-1073040072 https://api.github.com/repos/simonw/datasette/issues/1667 IC_kwDOBm6k_c4_9UrI simonw 9599 2022-03-19T16:34:02Z 2022-03-19T16:34:02Z OWNER

I called it as_format to avoid clashing with the Python built-in format() function when these things were turned into keyword arguments, but now that they're not I can use format instead.

I think I'm going to go with database, table, format and pks.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Make route matched pattern groups more consistent 1174302994  
1073039670 https://github.com/simonw/datasette/issues/1666#issuecomment-1073039670 https://api.github.com/repos/simonw/datasette/issues/1666 IC_kwDOBm6k_c4_9Uk2 simonw 9599 2022-03-19T16:31:08Z 2022-03-19T16:31:57Z OWNER

This does make it more interesting - it also highlights how inconsistent the way the capturing works is. Especially as_format which can be None or "" or .json or json or not used at all in the case of TableView.

https://github.com/simonw/datasette/blob/764738dfcb16cd98b0987d443f59d5baa9d3c332/tests/test_routes.py#L12-L36

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Refactor URL routing to enable testing 1174162781  
1073039241 https://github.com/simonw/datasette/issues/1666#issuecomment-1073039241 https://api.github.com/repos/simonw/datasette/issues/1666 IC_kwDOBm6k_c4_9UeJ simonw 9599 2022-03-19T16:28:15Z 2022-03-19T16:28:15Z OWNER

This is more interesting if it also asserts against the captured matches from the pattern.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Refactor URL routing to enable testing 1174162781  
1073037939 https://github.com/simonw/datasette/issues/878#issuecomment-1073037939 https://api.github.com/repos/simonw/datasette/issues/878 IC_kwDOBm6k_c4_9UJz simonw 9599 2022-03-19T16:19:30Z 2022-03-19T16:19:30Z OWNER

On revisiting https://gist.github.com/simonw/281eac9c73b062c3469607ad86470eb2 a few months later I'm having second thoughts about using @inject on the main() method.

But I still like the pattern as a way to resolve more complex cases like "to generate GeoJSON of the expanded view with labels, the label expansion code needs to run once at some before the GeoJSON formatting code does".

So I'm going to stick with it a tiny bit longer, but maybe try to make it a lot more explicit when it's going to happen rather than having the main view methods themselves also use async DI.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
New pattern for views that return either JSON or HTML, available for plugins 648435885  
1072954795 https://github.com/simonw/datasette/issues/1228#issuecomment-1072954795 https://api.github.com/repos/simonw/datasette/issues/1228 IC_kwDOBm6k_c4_8_2r Kabouik 7107523 2022-03-19T06:44:40Z 2022-03-19T06:44:40Z NONE

... unless your data had a column called n?

Exactly, that's highly likely even though I can't double check from this computer just now. Thanks!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error caused by faceting if a column called `n` exists 810397025  
1072939780 https://github.com/simonw/datasette/issues/1561#issuecomment-1072939780 https://api.github.com/repos/simonw/datasette/issues/1561 IC_kwDOBm6k_c4_88ME simonw 9599 2022-03-19T04:45:40Z 2022-03-19T04:45:40Z OWNER

I ended up moving hashed URL mode out to a plugin in: - #647

If you're still interested in using it with _memory please open an issue in that repo here: https://github.com/simonw/datasette-hashed-urls

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
add hash id to "_memory" url if hashed url mode is turned on and crossdb is also turned on 1082765654  
1072933875 https://github.com/simonw/datasette/issues/1666#issuecomment-1072933875 https://api.github.com/repos/simonw/datasette/issues/1666 IC_kwDOBm6k_c4_86vz simonw 9599 2022-03-19T04:03:42Z 2022-03-19T04:03:42Z OWNER

Tests so far: https://github.com/simonw/datasette/blob/711767bcd3c1e76a0861fe7f24069ff1c8efc97a/tests/test_routes.py#L12-L34

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Refactor URL routing to enable testing 1174162781  
1072915936 https://github.com/simonw/datasette/issues/1228#issuecomment-1072915936 https://api.github.com/repos/simonw/datasette/issues/1228 IC_kwDOBm6k_c4_82Xg simonw 9599 2022-03-19T01:50:27Z 2022-03-19T01:50:27Z OWNER

Demo: https://latest.datasette.io/fixtures/facetable - which now has a column called n.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error caused by faceting if a column called `n` exists 810397025  
1072908029 https://github.com/simonw/datasette/issues/1228#issuecomment-1072908029 https://api.github.com/repos/simonw/datasette/issues/1228 IC_kwDOBm6k_c4_80b9 simonw 9599 2022-03-19T00:57:54Z 2022-03-19T00:57:54Z OWNER

Yes! That's the problem. I was able to replicate it like so: echo '[{ "n": "one", "abc": 1 }, { "n": "one", "abc": 2 }, { "n": "two", "abc": 3 }]' | sqlite-utils insert column-called-n.db t -

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error caused by faceting if a column called `n` exists 810397025  
1072907680 https://github.com/simonw/datasette/issues/1228#issuecomment-1072907680 https://api.github.com/repos/simonw/datasette/issues/1228 IC_kwDOBm6k_c4_80Wg simonw 9599 2022-03-19T00:55:48Z 2022-03-19T00:55:48Z OWNER

... unless your data had a column called n?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error caused by faceting if a column called `n` exists 810397025  
1072907610 https://github.com/simonw/datasette/issues/1228#issuecomment-1072907610 https://api.github.com/repos/simonw/datasette/issues/1228 IC_kwDOBm6k_c4_80Va simonw 9599 2022-03-19T00:55:29Z 2022-03-19T00:55:29Z OWNER

It looks to me like something is causing the faceting query here to return a string when it was expected to return a number:

https://github.com/simonw/datasette/blob/32963018e7edfab1233de7c7076c428d0e5c7813/datasette/facets.py#L153-L170

I can't think of any way that a count(*) as n would turn into a string though!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error caused by faceting if a column called `n` exists 810397025  
1072907200 https://github.com/simonw/datasette/issues/1605#issuecomment-1072907200 https://api.github.com/repos/simonw/datasette/issues/1605 IC_kwDOBm6k_c4_80PA simonw 9599 2022-03-19T00:52:54Z 2022-03-19T00:53:45Z OWNER

Had a thought about the implementation of this: it could make a really neat plugin.

Something like datasette-export which adds a export command using https://docs.datasette.io/en/stable/plugin_hooks.html#register-commands-cli - then you could run:

datasette export my-export-dir mydatabase.db -m metadata.json --template-dir templates/

And the command would then:

  • Create a Datasette() instance with those databases/metadata/etc
  • Executeawait datasette.client.get("/") to get the homepage HTML
  • Parse the HTML using BeautifulSoup to find all a[href], link[href], script[src], img[src] elements that reference a relative path as opposed to one that starts with http://
  • Write out the homepage to my-export-dir/index.html
  • Recursively fetch and dump all of the other pages and assets that it found too

All of that HTML parsing may be over-complicating things. It could alternatively accept options for which pages you want to export:

datasette export my-export-dir \ mydatabase.db -m metadata.json --template-dir templates/ \ --path / \ --path /mydatabase ...

Or a really wild option: it could allow you to define the paths you want to export using a SQL query:

datasette export my-export-dir \ mydatabase.db -m metadata.json --template-dir templates/ \ --sql " select '/' as path, 'index.html' as filename union all select '/mydatabase/articles/' || id as path, 'article-' || id || '.html' as filename from articles union all select '/mydatabase/tags/' || tag as path, 'tag-' || tag || '.html' as filename from tags " Which would save these files: - index.html as the content of / - article-1.html (and more) as the content of /mydatabase/articles/1 - tag-python.html (and more) as the content of /mydatabase/tags/python

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Scripted exports 1108671952  
1072905467 https://github.com/simonw/datasette/issues/1662#issuecomment-1072905467 https://api.github.com/repos/simonw/datasette/issues/1662 IC_kwDOBm6k_c4_8zz7 simonw 9599 2022-03-19T00:42:23Z 2022-03-19T00:42:23Z OWNER

Those client-side SQLite tricks are really neat.

datasette publish defaults to configuring it so the raw SQLite database can be downloaded from /fixtures.db - and this issue updated it to be served with a CORS header that would allow client-side scripts to load the file:

  • 1057

If you're not going to run any server-side code at all you don't need Datasette for this - you can upload the SQLite database file to any static hosting with CORS headers and load it into the client that way.

In terms of static publishing, I do think there's something interesting about using Datasette to generate static sites. There's an issue discussing options for that over here:

  • 1605

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
[feature request] Publish to fully static website 1170497629  
1072904703 https://github.com/simonw/datasette/issues/1661#issuecomment-1072904703 https://api.github.com/repos/simonw/datasette/issues/1661 IC_kwDOBm6k_c4_8zn_ simonw 9599 2022-03-19T00:37:36Z 2022-03-19T00:37:36Z OWNER

Updated docs: https://docs.datasette.io/en/latest/performance.html#datasette-hashed-urls

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Remove Hashed URL mode 1170355774  
1072901159 https://github.com/simonw/datasette/issues/1661#issuecomment-1072901159 https://api.github.com/repos/simonw/datasette/issues/1661 IC_kwDOBm6k_c4_8ywn simonw 9599 2022-03-19T00:20:27Z 2022-03-19T00:20:27Z OWNER

I can remove the default_cache_ttl_hashed setting too.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Remove Hashed URL mode 1170355774  
1072898923 https://github.com/simonw/datasette/pull/1664#issuecomment-1072898923 https://api.github.com/repos/simonw/datasette/issues/1664 IC_kwDOBm6k_c4_8yNr simonw 9599 2022-03-19T00:11:33Z 2022-03-19T00:11:33Z OWNER

I'm going to land this and handle those in separate commits.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Remove hashed URL mode 1173017980  
1072898797 https://github.com/simonw/datasette/pull/1664#issuecomment-1072898797 https://api.github.com/repos/simonw/datasette/issues/1664 IC_kwDOBm6k_c4_8yLt simonw 9599 2022-03-19T00:11:09Z 2022-03-19T00:11:09Z OWNER

Still need to remove it from the documentation and do something about that hash_urls setting.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Remove hashed URL mode 1173017980  
1072890524 https://github.com/simonw/datasette/pull/1664#issuecomment-1072890524 https://api.github.com/repos/simonw/datasette/issues/1664 IC_kwDOBm6k_c4_8wKc simonw 9599 2022-03-18T23:44:33Z 2022-03-19T00:06:51Z OWNER

Looks like that was set here: https://github.com/simonw/datasette/blob/77a904fea14f743560af9cc668146339bdbbd0a9/datasette/views/base.py#L490-L492

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Remove hashed URL mode 1173017980  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 578.506ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows