From 182c3a3b45a37cd7d668ca65d884ec1fe28717b2 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 7 Jul 2023 13:28:59 +0200 Subject: [PATCH] gh-96165: Clarify omitting the FROM clause in SQLite queries. --- Doc/library/sqlite3.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index bc69387fca8a93..f6a8714519f59f 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -2519,6 +2519,13 @@ Queries now return :class:`!Row` objects: >>> row["RADIUS"] # Column names are case-insensitive. 6378 +.. note:: + + The ``FROM`` clause can be omitted in the ``SELECT`` statement, as in the + above example. In such cases, SQLite returns a single row with columns + defined by expressions, e.g. literals, with the given aliases + ``expr AS alias``. + You can create a custom :attr:`~Cursor.row_factory` that returns each row as a :class:`dict`, with column names mapped to values: