mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
[3.14] gh-133439: Fix dot commands with trailing spaces are mistaken for multi-line sqlite statements in the sqlite3 command-line interface (GH-133440) (GH-133738)
(cherry picked from commit ebd4881db2
)
Co-authored-by: Tan Long <tanloong@foxmail.com>
This commit is contained in:
parent
92d56777a1
commit
beb8a50ca1
3 changed files with 53 additions and 11 deletions
|
@ -48,17 +48,25 @@ class SqliteInteractiveConsole(InteractiveConsole):
|
|||
Return True if more input is needed; buffering is done automatically.
|
||||
Return False if input is a complete statement ready for execution.
|
||||
"""
|
||||
match source:
|
||||
case ".version":
|
||||
print(f"{sqlite3.sqlite_version}")
|
||||
case ".help":
|
||||
print("Enter SQL code and press enter.")
|
||||
case ".quit":
|
||||
sys.exit(0)
|
||||
case _:
|
||||
if not sqlite3.complete_statement(source):
|
||||
return True
|
||||
execute(self._cur, source)
|
||||
if not source or source.isspace():
|
||||
return False
|
||||
if source[0] == ".":
|
||||
match source[1:].strip():
|
||||
case "version":
|
||||
print(f"{sqlite3.sqlite_version}")
|
||||
case "help":
|
||||
print("Enter SQL code and press enter.")
|
||||
case "quit":
|
||||
sys.exit(0)
|
||||
case "":
|
||||
pass
|
||||
case _ as unknown:
|
||||
self.write("Error: unknown command or invalid arguments:"
|
||||
f' "{unknown}".\n')
|
||||
else:
|
||||
if not sqlite3.complete_statement(source):
|
||||
return True
|
||||
execute(self._cur, source)
|
||||
return False
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue