From bc1fe3549b32896ef0cbae3d2220ebeaf111d9b8 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 4 Oct 2023 06:48:31 -0700 Subject: [PATCH] [3.12] gh-109151: Enable readline in the sqlite3 CLI (GH-109152) (#110352) gh-109151: Enable readline in the sqlite3 CLI (GH-109152) (cherry picked from commit 254e30c487908a52a7545cea205aeaef5fbfeea4) Co-authored-by: Serhiy Storchaka --- Lib/sqlite3/__main__.py | 4 ++++ .../Library/2023-09-08-19-44-01.gh-issue-109151.GkzkQu.rst | 1 + 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2023-09-08-19-44-01.gh-issue-109151.GkzkQu.rst diff --git a/Lib/sqlite3/__main__.py b/Lib/sqlite3/__main__.py index 3b59763375c1..b93b84384a09 100644 --- a/Lib/sqlite3/__main__.py +++ b/Lib/sqlite3/__main__.py @@ -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 index 000000000000..78b4e882baba --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-09-08-19-44-01.gh-issue-109151.GkzkQu.rst @@ -0,0 +1 @@ +Enable ``readline`` editing features in the :ref:`sqlite3 command-line interface ` (``python -m sqlite3``). -- 2.47.3