html_url,issue_url,id,node_id,user,user_label,created_at,updated_at,author_association,body,reactions,issue,issue_label,performed_via_github_app https://github.com/simonw/datasette/issues/673#issuecomment-586455321,https://api.github.com/repos/simonw/datasette/issues/673,586455321,MDEyOklzc3VlQ29tbWVudDU4NjQ1NTMyMQ==,9599,simonw,2020-02-14T20:13:59Z,2020-02-14T20:13:59Z,OWNER,Closing this in favour of rethinking how sanity checks work.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586454371,https://api.github.com/repos/simonw/datasette/issues/673,586454371,MDEyOklzc3VlQ29tbWVudDU4NjQ1NDM3MQ==,9599,simonw,2020-02-14T20:11:02Z,2020-02-14T20:11:02Z,OWNER,"The technique from `run_sanity_checks` of running `PRAGMA table_info({})` for every table seems to work just fine. It failed for the Apple Photos database for example: ``` sqlite> pragma table_info(RKSceneInVersion_VirtualBufferReader); Error: no such module: VirtualBufferReaderModule ``` So I think the solution to this ticket is going to be moving that logic into a new utility function.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586450571,https://api.github.com/repos/simonw/datasette/issues/673,586450571,MDEyOklzc3VlQ29tbWVudDU4NjQ1MDU3MQ==,9599,simonw,2020-02-14T19:59:41Z,2020-02-14T20:01:14Z,OWNER,"This helped: ``` $ sqlite3 /tmp/hearst.db SQLite version 3.24.0 2018-06-04 14:10:15 Enter "".help"" for usage hints. sqlite> delete from spatial_ref_sys where srid != 4326; sqlitte> delete from spatial_ref_sys_aux where srid != 4326; sqlite> vacuum; sqlite> ^D $ ls -lah /tmp/hearst.db -rw-r--r-- 1 simonw wheel 216K Feb 14 12:01 /tmp/hearst.db ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586449286,https://api.github.com/repos/simonw/datasette/issues/673,586449286,MDEyOklzc3VlQ29tbWVudDU4NjQ0OTI4Ng==,9599,simonw,2020-02-14T19:56:00Z,2020-02-14T19:57:17Z,OWNER,"I tried to make the smallest SpatiaLite database file I could (to use for the tests), but it ended up over 5MB! ``` $ echo '{""type"":""Feature"",""properties"":{""name"":""Hearst Castle""},""geometry"":{""type"":""Point"",""coordinates"":[-121.1686,35.685]}}' | geojson-to-sqlite /tmp/hearst.db places - --spatialite $ ls -lah /tmp/hearst.db -rw-r--r-- 1 simonw wheel 5.3M Feb 14 11:54 /tmp/hearst.db ``` I imagine that's because of these tables: ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586448292,https://api.github.com/repos/simonw/datasette/issues/673,586448292,MDEyOklzc3VlQ29tbWVudDU4NjQ0ODI5Mg==,9599,simonw,2020-02-14T19:53:05Z,2020-02-14T19:53:05Z,OWNER,"I may be re-inventing this code at the moment: https://github.com/simonw/datasette/blob/3ffb8f3b98252531d11897fd431711e9b8045ace/datasette/app.py#L219-L237","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586445210,https://api.github.com/repos/simonw/datasette/issues/673,586445210,MDEyOklzc3VlQ29tbWVudDU4NjQ0NTIxMA==,9599,simonw,2020-02-14T19:44:27Z,2020-02-14T19:44:27Z,OWNER,For the unit tests I think I'm going to have to create minimal binary SQLite file examples and include them in the repo.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586444970,https://api.github.com/repos/simonw/datasette/issues/673,586444970,MDEyOklzc3VlQ29tbWVudDU4NjQ0NDk3MA==,9599,simonw,2020-02-14T19:43:46Z,2020-02-14T19:43:46Z,OWNER,`is_openable_sqlite` perhaps?,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586444835,https://api.github.com/repos/simonw/datasette/issues/673,586444835,MDEyOklzc3VlQ29tbWVudDU4NjQ0NDgzNQ==,9599,simonw,2020-02-14T19:43:27Z,2020-02-14T19:43:27Z,OWNER,"I can extend this function (maybe also rename it): https://github.com/simonw/datasette/blob/52ba34701cdbf510236de87d35b0e6df330626d1/datasette/utils/__init__.py#L595-L610","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586443837,https://api.github.com/repos/simonw/datasette/issues/673,586443837,MDEyOklzc3VlQ29tbWVudDU4NjQ0MzgzNw==,9599,simonw,2020-02-14T19:40:42Z,2020-02-14T19:41:56Z,OWNER,"Here's how to test if the `rtree` virtual table is supported: ``` >>> import sqlite3 >>> c = sqlite3.connect("":memory:"") >>> c.execute(""create virtual table blah using rtree (a, b, c)"") >>> c.execute(""create virtual table blah2 using rtree2 (a, b, c)"") Traceback (most recent call last): File """", line 1, in sqlite3.OperationalError: table blah already exists ``` Also: ``` >>> c.execute('''CREATE VIRTUAL TABLE SpatialIndex USING VirtualSpatialIndex()''') Traceback (most recent call last): File """", line 1, in sqlite3.OperationalError: no such module: VirtualSpatialIndex >>> c.enable_load_extension( ... True) >>> >>> c.load_extension(""/usr/local/lib/mod_spatialite.dylib"") >>> c.execute('''CREATE VIRTUAL TABLE SpatialIndex USING VirtualSpatialIndex()''') ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586442978,https://api.github.com/repos/simonw/datasette/issues/673,586442978,MDEyOklzc3VlQ29tbWVudDU4NjQ0Mjk3OA==,9599,simonw,2020-02-14T19:38:19Z,2020-02-14T19:38:19Z,OWNER,"Amazingly, I get 0 search results on Google for `RidList_VirtualReaderModule`! I guess no-one has reverse engineered the Apple Photos SQLite database at that level yet.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open, https://github.com/simonw/datasette/issues/673#issuecomment-586442292,https://api.github.com/repos/simonw/datasette/issues/673,586442292,MDEyOklzc3VlQ29tbWVudDU4NjQ0MjI5Mg==,9599,simonw,2020-02-14T19:36:37Z,2020-02-14T19:36:37Z,OWNER,This can be a function in `utils/__init__.py`.,"{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",565518772,Mechanism for checking if a SQLite database file is safe to open,