{"html_url": "https://github.com/simonw/datasette/issues/1151#issuecomment-747784199", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1151", "id": 747784199, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzc4NDE5OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T00:09:36Z", "updated_at": "2020-12-18T00:09:36Z", "author_association": "OWNER", "body": "Is it possible to connect to a memory database in read-only mode?\r\n\r\n`file:foo?mode=memory&cache=shared&mode=ro` isn't valid because it features `mode=` more than once.\r\n\r\nhttps://stackoverflow.com/a/40548682 suggests using `PRAGMA query_only` on the connection instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770448622, "label": "Database class mechanism for cross-connection in-memory databases"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1151#issuecomment-747801084", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1151", "id": 747801084, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwMTA4NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:01:26Z", "updated_at": "2020-12-18T01:01:26Z", "author_association": "OWNER", "body": "I tested this with a one-off plugin and it worked!\r\n\r\n```python\r\nfrom datasette import hookimpl\r\nfrom datasette.database import Database\r\n\r\n\r\n@hookimpl\r\ndef startup(datasette):\r\n datasette.add_database(\"statistics\", Database(\r\n datasette,\r\n memory_name=\"statistics\"\r\n ))\r\n```\r\nThis created a `/statistics` database when I ran `datasette` - and if I installed https://github.com/simonw/datasette-write I could then create tables in it which persisted until I restarted the server.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770448622, "label": "Database class mechanism for cross-connection in-memory databases"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1151#issuecomment-747801751", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1151", "id": 747801751, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwMTc1MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:03:39Z", "updated_at": "2020-12-18T01:03:39Z", "author_association": "OWNER", "body": "This feature is illustrated by the tests: https://github.com/simonw/datasette/blob/5e9895c67f08e9f42acedd3d6d29512ac446e15f/tests/test_internals_database.py#L469-L496\r\n\r\nI added new documentation for the `Datasette()` constructor here as well: https://docs.datasette.io/en/latest/internals.html#database-ds-path-none-is-mutable-false-is-memory-false-memory-name-none", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770448622, "label": "Database class mechanism for cross-connection in-memory databases"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747803268", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747803268, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwMzI2OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:08:40Z", "updated_at": "2020-12-18T01:08:40Z", "author_association": "OWNER", "body": "Next step: design a schema for the in-memory database table that exposes all of the tables.\r\n\r\nI want to support things like:\r\n\r\n- Show me all of the tables\r\n- Show me the columns in a table\r\n- Show me all tables that contain a `tags` column\r\n- Show me the indexes\r\n- Show me every table configured for full-text search\r\n\r\nMaybe a starting point would be to build concrete tables using the results of things like `PRAGMA foreign_key_list(table)` and `PRAGMA table_xinfo(table)` - note though that `table_xinfo` is SQLite 3.26.0 or higher, as shown here: https://github.com/simonw/datasette/blob/5e9895c67f08e9f42acedd3d6d29512ac446e15f/datasette/utils/__init__.py#L563-L579", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747804254", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747804254, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwNDI1NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:12:13Z", "updated_at": "2020-12-18T01:12:13Z", "author_association": "OWNER", "body": "Prototype: https://latest.datasette.io/fixtures?sql=select+%27facetable%27+as+%27table%27%2C+*+from+pragma_table_xinfo%28%27facetable%27%29%0D%0Aunion%0D%0Aselect+%27searchable%27+as+%27table%27%2C+*+from+pragma_table_xinfo%28%27searchable%27%29%0D%0Aunion%0D%0Aselect+%27compound_three_primary_keys%27+as+%27table%27%2C+*+from+pragma_table_xinfo%28%27compound_three_primary_keys%27%29\r\n\r\n```sql\r\nselect 'facetable' as 'table', * from pragma_table_xinfo('facetable')\r\nunion\r\nselect 'searchable' as 'table', * from pragma_table_xinfo('searchable')\r\nunion\r\nselect 'compound_three_primary_keys' as 'table', * from pragma_table_xinfo('compound_three_primary_keys')\r\n```\r\n\r\n\r\ntable | cid | name | type | notnull | dflt_value | pk | hidden\r\n-- | -- | -- | -- | -- | -- | -- | --\r\ncompound_three_primary_keys | 0 | pk1 | varchar(30) | 0 | \u00a0 | 1 | 0\r\ncompound_three_primary_keys | 1 | pk2 | varchar(30) | 0 | \u00a0 | 2 | 0\r\ncompound_three_primary_keys | 2 | pk3 | varchar(30) | 0 | \u00a0 | 3 | 0\r\ncompound_three_primary_keys | 3 | content | text | 0 | \u00a0 | 0 | 0\r\nfacetable | 0 | pk | integer | 0 | \u00a0 | 1 | 0\r\nfacetable | 1 | created | text | 0 | \u00a0 | 0 | 0\r\nfacetable | 2 | planet_int | integer | 0 | \u00a0 | 0 | 0\r\nfacetable | 3 | on_earth | integer | 0 | \u00a0 | 0 | 0\r\nfacetable | 4 | state | text | 0 | \u00a0 | 0 | 0\r\nfacetable | 5 | city_id | integer | 0 | \u00a0 | 0 | 0\r\nfacetable | 6 | neighborhood | text | 0 | \u00a0 | 0 | 0\r\nfacetable | 7 | tags | text | 0 | \u00a0 | 0 | 0\r\nfacetable | 8 | complex_array | text | 0 | \u00a0 | 0 | 0\r\nfacetable | 9 | distinct_some_null | \u00a0 | 0 | \u00a0 | 0 | 0\r\nsearchable | 0 | pk | integer | 0 | \u00a0 | 1 | 0\r\nsearchable | 1 | text1 | text | 0 | \u00a0 | 0 | 0\r\nsearchable | 2 | text2 | text | 0 | \u00a0 | 0 | 0\r\nsearchable | 3 | name with . and spaces | text | 0 | \u00a0 | 0 | 0", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747805275", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747805275, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwNTI3NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:15:27Z", "updated_at": "2020-12-18T01:16:17Z", "author_association": "OWNER", "body": "This query uses a join to pull foreign key information for every table: https://latest.datasette.io/fixtures?sql=with+tables+as+%28%0D%0A++select%0D%0A++++name%0D%0A++from%0D%0A++++sqlite_master%0D%0A++where%0D%0A++++type+%3D+%27table%27%0D%0A%29%0D%0Aselect%0D%0A++tables.name+as+%27table%27%2C%0D%0A++foo.*%0D%0Afrom%0D%0A++tables%0D%0A++join+pragma_foreign_key_list%28tables.name%29+foo\r\n\r\n```sql\r\nwith tables as (\r\n select\r\n name\r\n from\r\n sqlite_master\r\n where\r\n type = 'table'\r\n)\r\nselect\r\n tables.name as 'table',\r\n foo.*\r\nfrom\r\n tables\r\n join pragma_foreign_key_list(tables.name) foo\r\n```\r\n\r\nSame query for `pragma_table_xinfo`: https://latest.datasette.io/fixtures?sql=with+tables+as+%28%0D%0A++select%0D%0A++++name%0D%0A++from%0D%0A++++sqlite_master%0D%0A++where%0D%0A++++type+%3D+%27table%27%0D%0A%29%0D%0Aselect%0D%0A++tables.name+as+%27table%27%2C%0D%0A++foo.*%0D%0Afrom%0D%0A++tables%0D%0A++join+pragma_table_xinfo%28tables.name%29+foo", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747807289", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747807289, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwNzI4OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:22:05Z", "updated_at": "2020-12-18T01:22:05Z", "author_association": "OWNER", "body": "Here's a simpler query pattern (not using CTEs so should work on older versions of SQLite) - this one lists all indexes for all tables:\r\n```sql\r\nselect\r\n sqlite_master.name as 'table',\r\n indexes.*\r\nfrom\r\n sqlite_master\r\n join pragma_index_list(sqlite_master.name) indexes\r\nwhere\r\n sqlite_master.type = 'table'\r\n```\r\nhttps://latest.datasette.io/fixtures?sql=select%0D%0A++sqlite_master.name+as+%27table%27%2C%0D%0A++indexes.*%0D%0Afrom%0D%0A++sqlite_master%0D%0A++join+pragma_index_list%28sqlite_master.name%29+indexes%0D%0Awhere%0D%0A++sqlite_master.type+%3D+%27table%27", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747807891", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747807891, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwNzg5MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:23:59Z", "updated_at": "2020-12-18T01:23:59Z", "author_association": "OWNER", "body": "https://www.sqlite.org/pragma.html#pragfunc says:\r\n> * This feature is experimental and is subject to change. Further documentation will become available if and when the table-valued functions for PRAGMAs feature becomes officially supported. \r\n> * The table-valued functions for PRAGMA feature was added in SQLite version 3.16.0 (2017-01-02). Prior versions of SQLite cannot use this feature. ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747809670", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747809670, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgwOTY3MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T01:29:30Z", "updated_at": "2020-12-18T01:29:30Z", "author_association": "OWNER", "body": "I've been rediscovering the pattern I already documented in this TIL: https://github.com/simonw/til/blob/main/sqlite/list-all-columns-in-a-database.md#better-alternative-using-a-join", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747833639", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747833639, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgzMzYzOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T02:49:40Z", "updated_at": "2020-12-18T03:52:12Z", "author_association": "OWNER", "body": "I'm going to use five tables to start off with:\r\n\r\n- `databases` - a list of databases. Each one has a `name`, `path` (if it's on disk), `is_memory`, `schema_version`\r\n- `tables` - a list of tables. Each row is `database_name`, `table_name`, `sql` (the create table statement) - may add more tables in the future, in particular maybe a `last_row_count` to cache results of counting the rows.\r\n- `columns` - a list of columns. It's the output of `pragma_table_xinfo` with the `database_name` and `table_name` columns added at the beginning.\r\n- `foreign_keys` - a list of foreign keys - `pragma_foreign_key_list` output plus `database_name` and `table_name`.\r\n- `indexes` - a list of indexes - `pragma_table_xinfo` output plus `database_name` and `table_name`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747834113", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747834113, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgzNDExMw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T02:51:13Z", "updated_at": "2020-12-18T02:51:20Z", "author_association": "OWNER", "body": "SQLite uses `indexes` rather than `indices` as the plural, so I'll go with that: https://sqlite.org/lang_createindex.html", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747834462", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747834462, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgzNDQ2Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T02:52:19Z", "updated_at": "2020-12-18T02:52:26Z", "author_association": "OWNER", "body": "Maintaining this database will be the responsibility of a subclass of `Database` called `_SchemaDatabase` which will be managed by the `Datasette` instance.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747834762", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747834762, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzgzNDc2Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T02:53:22Z", "updated_at": "2020-12-18T02:53:22Z", "author_association": "OWNER", "body": "I think I'm going to have to build this without using the `pragma_x()` SQL functions as they were only added in 3.16 in 2017-01-02 and I've seen plenty of Datasette instances running on older versions of SQLite.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747847180", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747847180, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg0NzE4MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T03:35:15Z", "updated_at": "2020-12-18T03:35:15Z", "author_association": "OWNER", "body": "Simpler implementation idea: a Datasette method `.refresh_schemas()` which loops through all known databases, checks their schema version and updates the in-memory schemas database if they have changed.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747847405", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747847405, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg0NzQwNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T03:36:04Z", "updated_at": "2020-12-18T03:36:04Z", "author_association": "OWNER", "body": "I could have another table that stores the combined rows from `sqlite_m\u00e1ster` on every connected database so I have a copy of the schema SQL.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747861357", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747861357, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg2MTM1Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T04:32:52Z", "updated_at": "2020-12-18T04:32:52Z", "author_association": "OWNER", "body": "I need to figure out how this will interact with Datasette permissions.\r\n\r\nIf some tables are private, but others are public, should users be able to see the private tables listed in the schema metadata?\r\n\r\nIf not, how can that mechanism work?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747861556", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747861556, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg2MTU1Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T04:33:45Z", "updated_at": "2020-12-18T04:33:45Z", "author_association": "OWNER", "body": "One solution on permissions: if Datasette had an efficient way of saying \"list the tables that this user has access to\" I could use that as a filter any time the user views the schema information. The implementation could be tricky though.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747862001", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747862001, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg2MjAwMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T04:35:34Z", "updated_at": "2020-12-18T04:35:34Z", "author_association": "OWNER", "body": "I do need to solve the permissions problem properly though, because one of the goals of this system is to provide a paginated, searchable list of databases and tables for the homepage of the instance - #991.\r\n\r\nAs such, the homepage will need to be able to display only the tables and databases that the user has permission to view.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747864080", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747864080, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg2NDA4MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T04:43:29Z", "updated_at": "2020-12-18T04:43:29Z", "author_association": "OWNER", "body": "I may be overthinking that problem. Many queries are fast in SQLite. If a Datasette instance has 1,000 connected tables will even that be a performance problem for permission checks? I should benchmark to find out.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747864831", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747864831, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg2NDgzMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T04:46:18Z", "updated_at": "2020-12-18T04:46:18Z", "author_association": "OWNER", "body": "The homepage currently performs a massive flurry of permission checks - one for each, database, table and view: https://github.com/simonw/datasette/blob/0.53/datasette/views/index.py#L21-L75\r\n\r\nA paginated version of this is a little daunting as the permission checks would have to be carried out in every single table just to calculate the count that will be paginated.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1152#issuecomment-747891854", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1152", "id": 747891854, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg5MTg1NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T06:14:09Z", "updated_at": "2020-12-18T06:14:15Z", "author_association": "OWNER", "body": "This is a classic challenge in permissions systems. If I want Datasette to be able to handle thousands of tables I need a reasonable solution for it.\r\n\r\nTwitter conversation: https://twitter.com/simonw/status/1339791768842248192", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770598024, "label": "Efficiently calculate list of databases/tables a user can view"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1152#issuecomment-747892731", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1152", "id": 747892731, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg5MjczMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T06:16:29Z", "updated_at": "2020-12-18T06:16:29Z", "author_association": "OWNER", "body": "One enormous advantage I have is that after #1150 I will have a database table full of databases and tables that I can execute queries against.\r\n\r\nThis means I could calculate visible tables using SQL where clauses, which should be easily fast enough even against ten thousand plus tables.\r\n\r\nThe catch is the permissions hooks. Since I haven't hit Datasette 1.0 yet maybe I should redesign those hooks to work against the new in-memory database schema stuff?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770598024, "label": "Efficiently calculate list of databases/tables a user can view"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1152#issuecomment-747893423", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1152", "id": 747893423, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg5MzQyMw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T06:18:24Z", "updated_at": "2020-12-18T06:18:24Z", "author_association": "OWNER", "body": "What would Datasette's permission hooks look like if they all dealt with sets of items rather than individual items? So plugins could return a set of items that the user has permission to access, or even a WHERE clause?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770598024, "label": "Efficiently calculate list of databases/tables a user can view"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-747893704", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 747893704, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzg5MzcwNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T06:19:13Z", "updated_at": "2020-12-18T06:19:13Z", "author_association": "OWNER", "body": "I'm not going to block this issue on permissions - I will tackle the efficient bulk permissions problem in #1152.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1152#issuecomment-747919782", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1152", "id": 747919782, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzkxOTc4Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T07:27:01Z", "updated_at": "2020-12-18T07:27:01Z", "author_association": "OWNER", "body": "Perhaps this can be solved by keeping the existing plugin hooks and adding new, optional ones for bulk lookups.\r\n\r\nIf your plugin doesn't implement the bulk lookup hooks Datasette will do an inefficient loop through everything checking permissions on each one.\r\n\r\nIf you DO implement it you can speed things up dramatically.\r\n\r\nNot sure if this would solve the homepage problem though, where you might need to run 1,000 table permission checks. That's more a case where you want to think in terms of a SQL where clause.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770598024, "label": "Efficiently calculate list of databases/tables a user can view"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1152#issuecomment-747920087", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1152", "id": 747920087, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzkyMDA4Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T07:27:58Z", "updated_at": "2020-12-18T07:28:30Z", "author_association": "OWNER", "body": "I want to keep the existing `metadata.json` \"allow\" blocks mechanism working. Note that if you have 1,000 tables and a permissions policy you won't be using \"allow\" blocks, you'll be using a more sophisticated permissions plugin instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770598024, "label": "Efficiently calculate list of databases/tables a user can view"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1152#issuecomment-747920852", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1152", "id": 747920852, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzkyMDg1Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T07:30:22Z", "updated_at": "2020-12-18T07:30:22Z", "author_association": "OWNER", "body": "Redefining all Datasette permissions in terms of SQL queries that return the set of databases and tables that the user is allowed to interact with does feel VERY Datasette-y.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770598024, "label": "Efficiently calculate list of databases/tables a user can view"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1152#issuecomment-747921195", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1152", "id": 747921195, "node_id": "MDEyOklzc3VlQ29tbWVudDc0NzkyMTE5NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T07:31:25Z", "updated_at": "2020-12-18T07:31:25Z", "author_association": "OWNER", "body": "It's also a really good fit for the new mechanism that's coming together in #1150.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770598024, "label": "Efficiently calculate list of databases/tables a user can view"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/493#issuecomment-747966232", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/493", "id": 747966232, "node_id": "MDEyOklzc3VlQ29tbWVudDc0Nzk2NjIzMg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T09:19:41Z", "updated_at": "2020-12-18T09:19:41Z", "author_association": "OWNER", "body": "Is there any reason to keep `--setting` rather than moving those items into a `configure.json` file with all the configuration options that currently live in `metadata.json`?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 449886319, "label": "Rename metadata.json to config.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-748260118", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 748260118, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODI2MDExOA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T18:54:12Z", "updated_at": "2020-12-18T18:54:12Z", "author_association": "OWNER", "body": "I'm going to tidy this up and land it. A couple of additional decisions:\r\n\r\n- The database will be called `/_schemas`\r\n- By default it will only be visible to `root` - thus avoiding having to solve the permissions problem with regards to users seeing schemas for tables that are otherwise invisible to them.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-748260875", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 748260875, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODI2MDg3NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T18:55:12Z", "updated_at": "2020-12-18T18:55:12Z", "author_association": "OWNER", "body": "I'm going to move the code into a `utils/schemas.py` module, to avoid further extending the `Datasette` class definition and to make it more easily testable.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/493#issuecomment-748305976", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/493", "id": 748305976, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODMwNTk3Ng==", "user": {"value": 50527, "label": "jefftriplett"}, "created_at": "2020-12-18T20:34:39Z", "updated_at": "2020-12-18T20:34:39Z", "author_association": "CONTRIBUTOR", "body": "I can't keep up with the renaming contexts, but I like having the ability to run datasette+ datasette-ripgrep against different configs: \r\n\r\n```shell\r\ndatasette serve --metadata=./metadata.json\r\n```\r\n\r\nI have one for all of my code and one per client who has lots of code. So as long as I can point to datasette to something, it's easy to work with. ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 449886319, "label": "Rename metadata.json to config.json"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-748351350", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 748351350, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODM1MTM1MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T22:32:13Z", "updated_at": "2020-12-18T22:32:13Z", "author_association": "OWNER", "body": "Getting all the tests to pass is tricky because this adds a whole extra database to Datasette - and there's various code that loops through `ds.databases` as part of the tests.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-748352106", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 748352106, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODM1MjEwNg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T22:34:40Z", "updated_at": "2020-12-18T22:34:40Z", "author_association": "OWNER", "body": "Needs documentation, but I can wait to write that until I've tested out the feature a bit more.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1150#issuecomment-748354841", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1150", "id": 748354841, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODM1NDg0MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T22:43:49Z", "updated_at": "2020-12-18T22:43:49Z", "author_association": "OWNER", "body": "For a demo, visit https://latest.datasette.io/login-as-root and then hit https://latest.datasette.io/_schemas", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 770436876, "label": "Maintain an in-memory SQLite table of connected databases and their tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/509#issuecomment-748356637", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/509", "id": 748356637, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODM1NjYzNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T22:50:03Z", "updated_at": "2020-12-18T22:50:03Z", "author_association": "OWNER", "body": "Related problem caused by the new `_schemas` database - if a user attempts to open their own `_schemas.db` file it will fail. I'd like to open and mount that as `/_schemas_` instead.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 456568880, "label": "Support opening multiple databases with the same stem"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1155#issuecomment-748367922", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1155", "id": 748367922, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODM2NzkyMg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T23:15:24Z", "updated_at": "2020-12-18T23:15:24Z", "author_association": "OWNER", "body": "The code for building up that `.databases` dictionary is a bit convoluted. Here's the code that adds a `:memory:` database if the user specified `--memory` OR if there are no files to be attached:\r\n\r\nhttps://github.com/simonw/datasette/blob/ebc7aa287c99fe6114b79aeab8efb8d4489a6182/datasette/app.py#L221-L241\r\n\r\nI'm not sure why I wrote it this way, instead of just calling `.add_database(\":memory:\", Database(..., is_memory=True)`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 771216293, "label": "Better internal database_name for _internal database"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1155#issuecomment-748368384", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1155", "id": 748368384, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODM2ODM4NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T23:17:00Z", "updated_at": "2020-12-18T23:17:00Z", "author_association": "OWNER", "body": "Here's the commit where I added it. https://github.com/simonw/datasette/commit/9743e1d91b5f0a2b3c1c0bd6ffce8739341f43c4 - I didn't yet have the `.add_database()` mechanism. Today the `MEMORY` object bit is no longer needed.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 771216293, "label": "Better internal database_name for _internal database"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1155#issuecomment-748368938", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1155", "id": 748368938, "node_id": "MDEyOklzc3VlQ29tbWVudDc0ODM2ODkzOA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-12-18T23:19:04Z", "updated_at": "2020-12-18T23:19:04Z", "author_association": "OWNER", "body": "`Database` internal class is documented here: https://docs.datasette.io/en/latest/internals.html#database-class", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 771216293, "label": "Better internal database_name for _internal database"}, "performed_via_github_app": null}