{"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1606415188", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1606415188, "node_id": "IC_kwDOCGYnMM5fv_NU", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-06-26T01:46:47Z", "updated_at": "2023-06-26T01:47:01Z", "author_association": "OWNER", "body": "I just tested this in a brand new virtual environment using the macOS Python 3:\r\n```bash\r\npipenv shell --python /Applications/Xcode.app/Contents/Developer/usr/bin/python3\r\n```\r\nThen in that virtual environment I ran:\r\n```bash\r\npip install sqlite-utils\r\n# Confirm the right one is on the path:\r\nwhich sqlite-utils\r\n\r\ncurl \"https://data.nasa.gov/resource/y77d-th95.json\" | \\\r\n sqlite-utils insert meteorites.db meteorites - --pk=id\r\nsqlite-utils extract meteorites.db meteorites recclass\r\n```\r\nThis threw the same error reported above. Then I did this:\r\n```bash\r\nrm meteorites.db\r\npip install sqlean.py\r\n\r\ncurl \"https://data.nasa.gov/resource/y77d-th95.json\" | \\\r\n sqlite-utils insert meteorites.db meteorites - --pk=id\r\nsqlite-utils extract meteorites.db meteorites recclass\r\n```\r\nAnd that second time it worked correctly.", "reactions": "{\"total_count\": 1, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 1, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1606411508", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1606411508, "node_id": "IC_kwDOCGYnMM5fv-T0", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-06-26T01:42:10Z", "updated_at": "2023-06-26T01:42:22Z", "author_association": "OWNER", "body": "https://sqlite-utils.datasette.io/en/stable/changelog.html#v3-33 - upgrading to `sqlite-utils>=3.33` and then installing both `sqlean.py` and `sqlite-dump` in the same virtual environment as `sqlite-utils` should fix this issue.", "reactions": "{\"total_count\": 2, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 2, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1604379952", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1604379952, "node_id": "IC_kwDOCGYnMM5foOUw", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-06-23T14:39:55Z", "updated_at": "2023-06-23T15:39:32Z", "author_association": "OWNER", "body": "Ideally a workaround for this right now would be to install `pysqlite3` in the same virtual environment:\r\n\r\n sqlite-utils install pysqlite3-binary\r\n\r\nBut `pysqlite3-binary` doesn't yet ship a wheel for macOS so this probably won't work for most people.\r\n\r\nThe \"easiest\" fix at the moment is to use Python from Homebrew - so `brew install sqlite-utils` for example won't suffer from this problem. Not a great solution for people who aren't using Homebrew though!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1504288134", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1504288134, "node_id": "IC_kwDOCGYnMM5ZqZ2G", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-04-11T23:55:06Z", "updated_at": "2023-04-12T03:34:32Z", "author_association": "OWNER", "body": "Also checked the official Datasette Docker image - I had to run that in Codespaces because it doesn't currently work on my M2 Mac:\r\n\r\n```\r\ncodespace@codespaces-112c61:/workspaces/sqlite-utils$ docker pull datasetteproject/datasette\r\nUsing default tag: latest\r\n...\r\ncodespace@codespaces-112c61:/workspaces/sqlite-utils$ docker run -it datasetteproject/datasette /\r\nbin/bash\r\nroot@75ba34f501ec:/# python\r\nPython 3.11.0 (main, Dec 6 2022, 13:31:55) [GCC 10.2.1 20210110] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import sqlite3\r\n.executescript(\"\"\"\r\nPRAGMA writable_schema = 1;\r\nUPDATE sqlite_master SET sql = 'CREATE TABLE [foos] (id integer primary key)';\r\nPRAGMA writable_schema = 0;\r\n\"\"\")>>> db = sqlite3.connect(\":memory:\")\r\n>>> db.executescript(\"\"\"\r\n... PRAGMA writable_schema = 1;\r\n... UPDATE sqlite_master SET sql = 'CREATE TABLE [foos] (id integer primary key)';\r\n... PRAGMA writable_schema = 0;\r\n... \"\"\")\r\n\r\n>>>\r\n```\r\nSo that confirms that the official image also has a Python with a SQLite that's not in defensive mode.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1504245029", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1504245029, "node_id": "IC_kwDOCGYnMM5ZqPUl", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-04-11T23:13:41Z", "updated_at": "2023-04-11T23:14:39Z", "author_association": "OWNER", "body": "I also tested this against the current `ubuntu:latest` Docker image (on an M2 Mac), in Python 3.10 and 3.11:\r\n```\r\ndocker run -it ubuntu:latest /bin/bash\r\n```\r\nThen in the container:\r\n```\r\napt-get update\r\napt-get install python3\r\npython3\r\n# pasted in the above recipe\r\napt install software-properties-common\r\nadd-apt-repository ppa:deadsnakes/ppa\r\napt install python3.11\r\npython3.11 \r\n# pasted it in again\r\n```\r\nIn both cases the Python code did not raise an exception, which suggests that on Ubuntu those two Python versions do not have the defensive mode set.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1502559442", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1502559442, "node_id": "IC_kwDOCGYnMM5ZjzzS", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-04-11T01:32:30Z", "updated_at": "2023-04-11T01:33:27Z", "author_association": "OWNER", "body": "This seems to work:\r\n```python\r\nimport sqlite3\r\ndb = sqlite3.connect(\":memory:\")\r\ndb.executescript(\"\"\"\r\nPRAGMA writable_schema = 1;\r\nUPDATE sqlite_master SET sql = 'CREATE TABLE [foos] (id integer primary key)';\r\nPRAGMA writable_schema = 0;\r\n\"\"\")\r\n```\r\nIt succeeds on my Python 3.11 and raises the following exception on my broken Python 3.9:\r\n```\r\nsqlite3.OperationalError: table sqlite_master may not be modified\r\n```\r\nRemoving the `PRAGMA writable_schema = 1;` causes the same exception to be raised on both Pythons.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1502557629", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1502557629, "node_id": "IC_kwDOCGYnMM5ZjzW9", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-04-11T01:30:12Z", "updated_at": "2023-04-11T01:30:12Z", "author_association": "OWNER", "body": "I'll ask on the SQLite forum if it's possible to toggle that mode on and off using regular SQL. My hunch is that it isn't.\r\n\r\nIn which case `sqlite-utils` should at least know how to catch this error and display a much more readable error message, maybe with a link to further documentation.\r\n\r\nA utility function that can detect this mode would be really useful too. I'd probably have to do a test that tries to modify `sqlite_master` on a new in-memory database to catch if it's possible or not.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1502556111", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1502556111, "node_id": "IC_kwDOCGYnMM5Zjy_P", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-04-11T01:28:41Z", "updated_at": "2023-04-11T01:28:41Z", "author_association": "OWNER", "body": "Investigating this one now.\r\n\r\nThe `sqlite-utils` test suite passes without errors on my Python 3.11.2 installation... but it fails with this error on a Python 3.9.6 installation.\r\n\r\nIn the broken version's virtual environment directory I ran this:\r\n```\r\ncat pyvenv.cfg \r\nhome = /Applications/Xcode.app/Contents/Developer/usr/bin\r\nimplementation = CPython\r\nversion_info = 3.9.6.final.0\r\nvirtualenv = 20.17.1\r\ninclude-system-site-packages = false\r\nbase-prefix = /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9\r\nbase-exec-prefix = /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9\r\nbase-executable = /Applications/Xcode.app/Contents/Developer/usr/bin/python3\r\n```\r\nSo it looks like the Xcode `python3` has \"defensive\" mode turned on for SQLite.\r\n\r\nAs far as I can tell there's no way to turn it OFF again in Python.\r\n\r\nMy virtual environment that DOES work has this:\r\n\r\n```\r\nhome = /opt/homebrew/opt/python@3.11/bin\r\nimplementation = CPython\r\nversion_info = 3.11.2.final.0\r\nvirtualenv = 20.17.1\r\ninclude-system-site-packages = false\r\nbase-prefix = /opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11\r\nbase-exec-prefix = /opt/homebrew/opt/python@3.11/Frameworks/Python.framework/Versions/3.11\r\nbase-executable = /opt/homebrew/opt/python@3.11/bin/python3.11\r\n```\r\nSo the Python 3.11 I installed through Homebrew doesn't exhibit this bug.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1495780111", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1495780111, "node_id": "IC_kwDOCGYnMM5ZJ8sP", "user": {"value": 19786848, "label": "Thomascountz"}, "created_at": "2023-04-04T11:09:56Z", "updated_at": "2023-04-04T11:13:40Z", "author_association": "NONE", "body": "@wpears' workaround also worked for me, but also required me to manually set `PRAGMA writable_schema`.\r\n\r\n```sql\r\nPRAGMA writable_schema = 1;\r\nUPDATE sqlite_master SET sql = 'CREATE TABLE [foos] (...)'\r\nPRAGMA writable_schema = 0;\r\n```\r\n\r\n```shell\r\n$ python --version\r\nPython 3.11.2\r\n\r\n$ sqlite3 --version\r\n3.41.2 2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da\r\n\r\n$ sqlite-utils --version\r\nsqlite-utils, version 3.30\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1492777509", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1492777509, "node_id": "IC_kwDOCGYnMM5Y-fol", "user": {"value": 9020979, "label": "hydrosquall"}, "created_at": "2023-04-01T01:31:48Z", "updated_at": "2023-04-01T01:31:48Z", "author_association": "NONE", "body": "My current workaround is to use this library from a python script instead of as a CLI tool.\r\n\r\nThis lets me set the foreign key constraint at table creation time, instead of trying to modify an existing table. [docs](https://sqlite-utils.datasette.io/en/stable/python-api.html#specifying-foreign-keys)\r\n\r\nI found this [stackoverflow helpful](https://stackoverflow.com/a/1884841/5129731), as it explained that Sqlite doesn't support modifying existing tables directly.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1354192168", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1354192168, "node_id": "IC_kwDOCGYnMM5Qt1Uo", "user": {"value": 9020979, "label": "hydrosquall"}, "created_at": "2022-12-16T04:35:30Z", "updated_at": "2022-12-16T04:35:38Z", "author_association": "NONE", "body": "A related historical problem:\r\n\r\nhttps://github.com/tekartik/sqflite/issues/525#issuecomment-714500720\r\n\r\nI wonder if the version of Sqlite or Python for Intel chip have defensive mode disabled by default, whereas M1 chips versions have it enabled.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1354160286", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1354160286, "node_id": "IC_kwDOCGYnMM5Qttie", "user": {"value": 9020979, "label": "hydrosquall"}, "created_at": "2022-12-16T03:51:19Z", "updated_at": "2022-12-16T03:52:13Z", "author_association": "NONE", "body": "Hi @ryascott, thanks for sharing this! How did you upgrade your sqlite3 version? I'm running into this issue (also on an m1) with \r\n\r\n`Python ==3.10.7 sqlite3.sqlite_version==3.37.0 sqlite-utils==3.30`\r\n\r\nUnfortunately, `3.10.8` isn't listed in `pyenv` so I'm unable to install it.\r\n\r\nFor me, the trigger is trying to use the `add-foreign-key` command on its own:\r\n\r\n```bash\r\nsqlite-utils add-foreign-key library.db book_creators creator_id creators id\r\n```\r\n\r\nSome stackoverflow searching suggests that brew installing sqlite may fix it ( https://stackoverflow.com/questions/26345972/how-do-i-upgrade-the-sqlite-version-used-by-pythons-sqlite3-module-on-mac ), but I don't want to risk breaking the version of sqlite used by some other system, I'd only like to upgrade sqlite3 inside my current virtual environment.\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1304539296", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1304539296, "node_id": "IC_kwDOCGYnMM5NwbCg", "user": {"value": 559711, "label": "ryascott"}, "created_at": "2022-11-05T12:40:12Z", "updated_at": "2022-11-05T12:40:12Z", "author_association": "NONE", "body": "I had the problem this morning when running:\r\n\r\n`Python==3.9.6\r\n sqlite3.sqlite_version==3.37.0\r\n sqlite-utils==3.30\r\n`\r\n\r\nI upgraded to:\r\n`Python ==3.10.8 \r\n sqlite3.sqlite_version==3.37.2\r\n sqlite-utils==3.30\r\n`\r\n\r\nand the error did not appear anymore.\r\n\r\nHope this helps\r\nRyan\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1223378004", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1223378004, "node_id": "IC_kwDOCGYnMM5I60RU", "user": {"value": 1558033, "label": "wpears"}, "created_at": "2022-08-23T00:44:11Z", "updated_at": "2022-08-23T00:44:11Z", "author_association": "NONE", "body": "This bug affects me as well. Env:\r\n\r\n```\r\nPython 3.8.12\r\nsqlite-utils, version 3.28\r\nsqlite3 3.32.3\r\nMacOS Big Sur 11.6.7\r\nIntel\r\n```\r\n\r\nSimilar to @mdrovdahl, I was able to work around this bug by piping the SQL string constructed in `add_foreign_keys` to the `sqlite3` command itself. Specifically, if you're trying to patch this yourself, replace [lines 1026-1039 of db.py in your site packages](https://github.com/simonw/sqlite-utils/blob/main/sqlite_utils/db.py#L1026-L1039) with something similar to the following:\r\n\r\n```\r\nprint(\"PRAGMA writable_schema = 1;\")\r\nfor table_name, new_sql in table_sql.items():\r\n print(\"UPDATE sqlite_master SET sql = '{}' WHERE name = '{}';\".format(\r\n new_sql, table_name)\r\n )\r\nprint(\"PRAGMA writable_schema = 0;\")\r\nprint(\"VACUUM;\")\r\n```\r\n \r\nThen from your terminal:\r\n`db-to-sqlite \"\" your.db --all > output.sql && sqlite3 your.db < output.sql`\r\n\r\nIf you want to run this with `-p`, you'll have to actually open a file in code to write to instead of redirecting the output.", "reactions": "{\"total_count\": 3, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 3, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1206241356", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1206241356, "node_id": "IC_kwDOCGYnMM5H5chM", "user": {"value": 503614, "label": "lfdebrux"}, "created_at": "2022-08-05T09:26:15Z", "updated_at": "2022-08-05T09:29:42Z", "author_association": "NONE", "body": "I am getting the same error when using github-to-sqlite (which uses sqlite-utils internally). I am also using an M1 MacBook Pro, with macOS Monterey 12.5, with Python 3.10.6 for arm64 installed using pyenv. I have sqlite-utils 3.28 installed.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1198414383", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1198414383, "node_id": "IC_kwDOCGYnMM5Hblov", "user": {"value": 474467, "label": "mdrovdahl"}, "created_at": "2022-07-28T17:10:06Z", "updated_at": "2022-07-28T17:10:06Z", "author_association": "NONE", "body": "I was able to fight through this by capturing the SQL commands from the `add_foreign_keys()` function in sqlite-utils and then executing them manually via the sqlite3 client, first setting PRAGMA writable_schema on and then updating the sqlite_master table. Still no clue why they were failing when run in context...", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1172766270", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1172766270, "node_id": "IC_kwDOCGYnMM5F5v4-", "user": {"value": 474467, "label": "mdrovdahl"}, "created_at": "2022-07-01T22:40:26Z", "updated_at": "2022-07-01T22:40:26Z", "author_association": "NONE", "body": "Note, I do not get this issue using my Intel MacBook Pro =/\r\n\r\nEnvironment\r\n```\r\nmarkd@Marks-MBP metabase % python3 --version\r\nPython 3.9.13\r\nmarkd@Marks-MBP metabase % sqlite3 --version\r\n3.37.0 2021-12-09 01:34:53 9ff244ce0739f8ee52a3e9671adb4ee54c83c640b02e3f9d185fd2f9a179aapl\r\nmarkd@Marks-MBP metabase % sqlite-utils --version\r\nsqlite-utils, version 3.27\r\nmarkd@Marks-MBP metabase % sqlite3 github.db \r\nSQLite version 3.37.0 2021-12-09 01:34:53\r\nEnter \".help\" for usage hints.\r\nsqlite> .dbconfig\r\n defensive off\r\n dqs_ddl on\r\n dqs_dml on\r\n enable_fkey off\r\n enable_qpsg off\r\n enable_trigger on\r\n enable_view on\r\n fts3_tokenizer off\r\n legacy_alter_table on\r\n legacy_file_format off\r\n load_extension off\r\n no_ckpt_on_close off\r\n reset_database off\r\n trigger_eqp off\r\n trusted_schema on\r\n writable_schema off\r\n```\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/235#issuecomment-1172697090", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/235", "id": 1172697090, "node_id": "IC_kwDOCGYnMM5F5fAC", "user": {"value": 474467, "label": "mdrovdahl"}, "created_at": "2022-07-01T20:37:40Z", "updated_at": "2022-07-01T20:37:55Z", "author_association": "NONE", "body": "I just ran into what appears to be the same issue on a MacBook Pro, M1 Pro. \r\n\r\nEnvironment:\r\n```\r\nmarkd@Marks-MacBook-Pro metabase % python --version \r\nPython 3.8.9\r\nmarkd@Marks-MacBook-Pro metabase % sqlite3 --version \r\n3.37.0 2021-12-09 01:34:53 9ff244ce0739f8ee52a3e9671adb4ee54c83c640b02e3f9d185fd2f9a179aapl\r\nmarkd@Marks-MacBook-Pro metabase % sqlite-utils --version \r\nsqlite-utils, version 3.27\r\nmarkd@Marks-MacBook-Pro metabase % sqlite3 gh.db \r\nSQLite version 3.37.0 2021-12-09 01:34:53\r\nEnter \".help\" for usage hints.\r\nsqlite> .dbconfig\r\n defensive off\r\n dqs_ddl on\r\n dqs_dml on\r\n enable_fkey off\r\n enable_qpsg off\r\n enable_trigger on\r\n enable_view on\r\n fts3_tokenizer off\r\n legacy_alter_table on\r\n legacy_file_format off\r\n load_extension off\r\n no_ckpt_on_close off\r\n reset_database off\r\n trigger_eqp off\r\n trusted_schema on\r\n writable_schema off\r\n``` \r\n\r\nError\r\n```\r\nmarkd@Marks-MacBook-Pro metabase % github-to-sqlite repos gh.db a8cteam51 \r\nTraceback (most recent call last):\r\n File \"/Users/markd/Library/Python/3.8/bin/github-to-sqlite\", line 8, in \r\n sys.exit(cli())\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/click/core.py\", line 1130, in __call__\r\n return self.main(*args, **kwargs)\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/click/core.py\", line 1055, in main\r\n rv = self.invoke(ctx)\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/click/core.py\", line 1657, in invoke\r\n return _process_result(sub_ctx.command.invoke(sub_ctx))\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/click/core.py\", line 1404, in invoke\r\n return ctx.invoke(self.callback, **ctx.params)\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/click/core.py\", line 760, in invoke\r\n return __callback(*args, **kwargs)\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/github_to_sqlite/cli.py\", line 268, in repos\r\n utils.ensure_db_shape(db)\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/github_to_sqlite/utils.py\", line 688, in ensure_db_shape\r\n ensure_foreign_keys(db)\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/github_to_sqlite/utils.py\", line 682, in ensure_foreign_keys\r\n db[table].add_foreign_key(column, table2, column2)\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/sqlite_utils/db.py\", line 2004, in add_foreign_key\r\n self.db.add_foreign_keys([(self.name, column, other_table, other_column)])\r\n File \"/Users/markd/Library/Python/3.8/lib/python/site-packages/sqlite_utils/db.py\", line 1019, in add_foreign_keys\r\n cursor.execute(\r\nsqlite3.OperationalError: table sqlite_master may not be modified\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 810618495, "label": "Extract columns cannot create foreign key relation: sqlite3.OperationalError: table sqlite_master may not be modified"}, "performed_via_github_app": null}