]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
doc: Update connection example (#9926)
authorInada Naoki <songofacandy@gmail.com>
Sat, 10 Jun 2023 18:34:07 +0000 (03:34 +0900)
committerGitHub <noreply@github.com>
Sat, 10 Jun 2023 18:34:07 +0000 (20:34 +0200)
Row object is now namedtuple-like.

doc/build/core/connections.rst

index f2d0f4f5ae27b683802069bf21225afa7cc661a2..dc71fab28e9afa12c3414076f22859a522566c50 100644 (file)
@@ -48,7 +48,7 @@ a textual statement to the database looks like::
     with engine.connect() as connection:
         result = connection.execute(text("select username from users"))
         for row in result:
-            print("username:", row["username"])
+            print("username:", row.username)
 
 Above, the :meth:`_engine.Engine.connect` method returns a :class:`_engine.Connection`
 object, and by using it in a Python context manager (e.g. the ``with:``