{"html_url": "https://github.com/simonw/datasette/issues/2001#issuecomment-1403084856", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2001", "id": 1403084856, "node_id": "IC_kwDOBm6k_c5ToWA4", "user": {"value": 193185, "label": "cldellow"}, "created_at": "2023-01-25T04:31:02Z", "updated_at": "2023-01-25T04:31:02Z", "author_association": "CONTRIBUTOR", "body": "Aha, it's user error on my part.\r\n\r\nAdding\r\n\r\n```\r\nsqlite3_db_config.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int]\r\n```\r\n\r\nmakes it work reliably both on the CLI and from datasette, and now I can reproduce the errors you mentioned in the issue description.", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1553615704, "label": "Datasette is not compatible with SQLite's strict quoting compilation option"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2001#issuecomment-1403078134", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2001", "id": 1403078134, "node_id": "IC_kwDOBm6k_c5ToUX2", "user": {"value": 193185, "label": "cldellow"}, "created_at": "2023-01-25T04:20:43Z", "updated_at": "2023-01-25T04:22:28Z", "author_association": "CONTRIBUTOR", "body": "I'm on Ubuntu, unfortunately. :( Would it still be relevant?\r\n\r\nI think I've narrowed things down a bit more.\r\n\r\nEven `sqlite3_free(sqlite3_malloc(128))` segfaults -- this suggests to me that it's something about the sqlite3 library that was loaded, vs, say, getting the wrong db handle when I go spelunking in the Connection object.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1553615704, "label": "Datasette is not compatible with SQLite's strict quoting compilation option"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2001#issuecomment-1403053144", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2001", "id": 1403053144, "node_id": "IC_kwDOBm6k_c5ToORY", "user": {"value": 193185, "label": "cldellow"}, "created_at": "2023-01-25T03:34:53Z", "updated_at": "2023-01-25T03:34:53Z", "author_association": "CONTRIBUTOR", "body": "Your comment introduced me to this issue in sqlite and to the `ctypes` module - thanks!\r\n\r\n> I also hope that the datasette developers will enable this mode in a test environment [...]\r\n> perhaps we could figure out how to invoke it using `ctypes`\r\n\r\nI'm not a Datasette developer, but I _am_ curious to learn more about getting unholy access to the sqlite C APIs inside of Datasette. (Such access could also help #1293, and if done without grovelling inside of pysqlite's Connection object for the db handle, could even be relatively safe.)\r\n\r\nI experimented a bit. I came up with https://gist.github.com/cldellow/85bba507c314b127f85563869cd94820\r\n\r\nIf you run `python3 enable-strict-quoting-sqlite3.py`, it seems to set those flags correctly -- `SELECT \"foo\"` fails where it would normally succeed.\r\n\r\nBut if you put it in a `plugins/` dir and run `datasette --plugins-dir plugins/`, it segfaults when it tries to call `sqlite3_db_config` on the connections created by Datasette.\r\n\r\nI am... confused. I'm _pretty_ sure I'm using the same python and the same libsqlite3 in both scenarios, so I would expect it to work.\r\n\r\n@gwk do you know anything that might help me debug the segfault? I gather that my approach of going grovelling inside of a `PyObject` is particularly dangerous, but I was thinking (a) it's necessary in order to test Datasette's use of the sqlite3 library and (b) even if it's not portable, it'd be good enough for running the tests on a single machine.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1553615704, "label": "Datasette is not compatible with SQLite's strict quoting compilation option"}, "performed_via_github_app": null}