]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-109151: Enable readline in the sqlite3 CLI (GH-109152) (#110352)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 4 Oct 2023 13:48:31 +0000 (06:48 -0700)
committerGitHub <noreply@github.com>
Wed, 4 Oct 2023 13:48:31 +0000 (15:48 +0200)
gh-109151: Enable readline in the sqlite3 CLI (GH-109152)
(cherry picked from commit 254e30c487908a52a7545cea205aeaef5fbfeea4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/sqlite3/__main__.py
Misc/NEWS.d/next/Library/2023-09-08-19-44-01.gh-issue-109151.GkzkQu.rst [new file with mode: 0644]

index 3b59763375c147477b303ff468d1ba358e3a39cd..b93b84384a092582455aedde0ea715bcb179dd24 100644 (file)
@@ -116,6 +116,10 @@ def main(*args):
         else:
             # No SQL provided; start the REPL.
             console = SqliteInteractiveConsole(con)
+            try:
+                import readline
+            except ImportError:
+                pass
             console.interact(banner, exitmsg="")
     finally:
         con.close()
diff --git a/Misc/NEWS.d/next/Library/2023-09-08-19-44-01.gh-issue-109151.GkzkQu.rst b/Misc/NEWS.d/next/Library/2023-09-08-19-44-01.gh-issue-109151.GkzkQu.rst
new file mode 100644 (file)
index 0000000..78b4e88
--- /dev/null
@@ -0,0 +1 @@
+Enable ``readline`` editing features in the :ref:`sqlite3 command-line interface <sqlite3-cli>` (``python -m sqlite3``).