Skip to content

Commit 75299dc

Browse files
[3.10] gh-95273: Improve sqlite3.complete_statement docs (GH-95840) (#95918)
Co-authored-by: Ezio Melotti <[email protected]> Co-authored-by: CAM Gerlach <[email protected]>. (cherry picked from commit e6623e7) Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent bfaa071 commit 75299dc

File tree

2 files changed

+16
-38
lines changed

2 files changed

+16
-38
lines changed

Doc/includes/sqlite3/complete_statement.py

-30
This file was deleted.

Doc/library/sqlite3.rst

+16-8
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,22 @@ Module functions
222222

223223
.. function:: complete_statement(statement)
224224

225-
Returns ``True`` if the string *statement* contains one or more complete SQL
226-
statements terminated by semicolons. It does not verify that the SQL is
227-
syntactically correct, only that there are no unclosed string literals and the
228-
statement is terminated by a semicolon.
229-
230-
This can be used to build a shell for SQLite, as in the following example:
231-
232-
.. literalinclude:: ../includes/sqlite3/complete_statement.py
225+
Return ``True`` if the string *statement* appears to contain
226+
one or more complete SQL statements.
227+
No syntactic verification or parsing of any kind is performed,
228+
other than checking that there are no unclosed string literals
229+
and the statement is terminated by a semicolon.
230+
231+
For example::
232+
233+
>>> sqlite3.complete_statement("SELECT foo FROM bar;")
234+
True
235+
>>> sqlite3.complete_statement("SELECT foo")
236+
False
237+
238+
This function may be useful during command-line input
239+
to determine if the entered text seems to form a complete SQL statement,
240+
or if additional input is needed before calling :meth:`~Cursor.execute`.
233241

234242
.. function:: enable_callback_tracebacks(flag, /)
235243

0 commit comments

Comments
 (0)