Title: sqlite3.iterdump() incompatible with binary data · Issue #108590 · python/cpython · GitHub
Open Graph Title: sqlite3.iterdump() incompatible with binary data · Issue #108590 · python/cpython
X Title: sqlite3.iterdump() incompatible with binary data · Issue #108590 · python/cpython
Description: Bug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CPython versions tested on: 3.11 Operating...
Open Graph Description: Bug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CP...
X Description: Bug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CP...
Opengraph URL: https://github.com/python/cpython/issues/108590
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"sqlite3.iterdump() incompatible with binary data","articleBody":"# Bug report\n\n### Checklist\n\n- [X] I am confident this is a bug in CPython, not a bug in a third-party project\n- [X] I have searched the [CPython issue tracker](https://github.com/python/cpython/issues?q=is%3Aissue+sort%3Acreated-desc),\nand am confident this bug has not been reported before\n\n\n### CPython versions tested on:\n\n3.11\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.11.5 (main, Aug 25 2023, 13:19:53) [GCC 9.4.0]\n\n### A clear and concise description of the bug:\n\nApologies if I'm misunderstanding. Please advice if I should post elsewhere. But shouldn't iterdump() properly detect VARCHAR columns with binary data and output X'' strings instead of throwing an error? This is what `sqlite3 .dump` does.\n\n```python\nimport sqlite3\nwith sqlite3.connect(db_path) as conn:\n with open(dump_path, 'w') as dump:\n for line in conn.iterdump():\n pass\n```\n\nThe above will throw an error:\n```\n File \"foo.py\", line 79, in dump_sqlite_db\n for line in conn.iterdump():\n File \"/usr/lib/python3.11/sqlite3/dump.py\", line 63, in _iterdump\n for row in query_res:\nsqlite3.OperationalError: Could not decode to UTF-8 column ''INSERT INTO \"sync_entities_metadata\" VALUES('||quote(\"storage_key\")||','||quote(\"metadata\")||')'' with text 'INSERT INTO \"sync_entities_metadata\" VALUES(1,'v10����\n```\n\nI tried enabling `conn.text_factory = bytes` as a workaround, but now get a different error.\n```\n File \"foo.py\", line 79, in dump_sqlite_db\n for line in conn.iterdump():\n File \"/usr/lib/python3.11/sqlite3/dump.py\", line 43, in _iterdump\n elif table_name.startswith('sqlite_'):\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: startswith first arg must be bytes or a tuple of bytes, not str\n```\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-108657\n* gh-108673\n* gh-108674\n* gh-108683\n* gh-108686\n* gh-108694\n* gh-108695\n* gh-108699\n* gh-111324\n* gh-111325\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/dotysan","@type":"Person","name":"dotysan"},"datePublished":"2023-08-28T21:58:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":32},"url":"https://github.com/108590/cpython/issues/108590"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4d5e9c73-9292-4c01-fb47-52121d881c6a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 902E:83877:B15A3:FAF1F:696A157A |
| html-safe-nonce | 6ed48e4a040c8bf0a78385582484bbe0474ba0ed6b1508f00772efa56b28cdd1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDJFOjgzODc3OkIxNUEzOkZBRjFGOjY5NkExNTdBIiwidmlzaXRvcl9pZCI6IjM1Mjk1MDA3NTAwNTM1MTI1NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 600a9dea5920b26264dd83975579b898c67ef3d33f68fad95e431ead09c1acf4 |
| hovercard-subject-tag | issue:1870565953 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/108590/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a042737d86cc638c99e50ecbf859f406974b348c0e04756775c1cf2695f41f3e/python/cpython/issues/108590 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a042737d86cc638c99e50ecbf859f406974b348c0e04756775c1cf2695f41f3e/python/cpython/issues/108590 |
| og:image:alt | Bug report Checklist I am confident this is a bug in CPython, not a bug in a third-party project I have searched the CPython issue tracker, and am confident this bug has not been reported before CP... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dotysan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 34a52bd10bd674f68e5c1b6b74413b79bf2ca20c551055ace3f7cdd112803923 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e8bd37502700f365b18a4d39acf7cb7947e11b1a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width