Skip to content

Commit

Permalink
[3.10] gh-95273: Improve sqlite3.complete_statement docs (GH-95840) (#…
Browse files Browse the repository at this point in the history
…95918)

Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>.
(cherry picked from commit e6623e7)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
erlend-aasland committed Aug 12, 2022
1 parent bfaa071 commit 75299dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 38 deletions.
30 changes: 0 additions & 30 deletions Doc/includes/sqlite3/complete_statement.py

This file was deleted.

24 changes: 16 additions & 8 deletions Doc/library/sqlite3.rst
Expand Up @@ -222,14 +222,22 @@ Module functions

.. function:: complete_statement(statement)

Returns ``True`` if the string *statement* contains one or more complete SQL
statements terminated by semicolons. It does not verify that the SQL is
syntactically correct, only that there are no unclosed string literals and the
statement is terminated by a semicolon.

This can be used to build a shell for SQLite, as in the following example:

.. literalinclude:: ../includes/sqlite3/complete_statement.py
Return ``True`` if the string *statement* appears to contain
one or more complete SQL statements.
No syntactic verification or parsing of any kind is performed,
other than checking that there are no unclosed string literals
and the statement is terminated by a semicolon.

For example::

>>> sqlite3.complete_statement("SELECT foo FROM bar;")
True
>>> sqlite3.complete_statement("SELECT foo")
False

This function may be useful during command-line input
to determine if the entered text seems to form a complete SQL statement,
or if additional input is needed before calling :meth:`~Cursor.execute`.

.. function:: enable_callback_tracebacks(flag, /)

Expand Down

0 comments on commit 75299dc

Please sign in to comment.