@@ -413,6 +413,17 @@ Connection Objects
413
413
414
414
.. class :: Connection
415
415
416
+ Each open SQLite database is represented by a connection object.
417
+ A connection object is created with :func: `sqlite3.connect `.
418
+ The main purpose of connection objects is creating
419
+ :class: `cursors objects <Cursor> `,
420
+ and :ref: `sqlite3-controlling-transactions `.
421
+
422
+ .. seealso ::
423
+
424
+ * :ref: `sqlite3-connection-shortcuts `
425
+ * :ref: `sqlite3-connection-context-manager `
426
+
416
427
An SQLite database connection has the following attributes and methods:
417
428
418
429
.. attribute :: isolation_level
@@ -957,6 +968,20 @@ Connection Objects
957
968
Cursor Objects
958
969
--------------
959
970
971
+ A cursor object represents a database cursor,
972
+ which is used to execute SQL statements,
973
+ and manage the context of a fetch operation.
974
+ Cursors are created with :meth: `Connection.cursor `,
975
+ or by using any of the :ref: `connection shortcut methods
976
+ <sqlite3-connection-shortcuts>`.
977
+
978
+ Cursors objects are :term: `iterators <iterator> `,
979
+ meaning that if you :meth: `execute ` a ``SELECT `` query,
980
+ you can simply iterate over the cursor to fetch the resulting rows::
981
+
982
+ for row in cur.execute("select * from data"):
983
+ print(row)
984
+
960
985
.. class :: Cursor
961
986
962
987
A :class: `Cursor ` instance has the following attributes and methods.
@@ -1111,15 +1136,13 @@ Row Objects
1111
1136
1112
1137
.. class :: Row
1113
1138
1114
- A :class: `Row ` instance serves as a highly optimized
1139
+ A :class: `Row ` instance that serves as a highly optimized
1115
1140
:attr: `~Connection.row_factory ` for :class: `Connection ` objects.
1116
- It tries to mimic a tuple in most of its features.
1117
-
1118
- It supports mapping access by column name and index, iteration,
1141
+ It tries to mimic a :class: `tuple ` in most of its features,
1142
+ and supports :term: `mapping ` access by column name and index, iteration,
1119
1143
representation, equality testing and :func: `len `.
1120
1144
1121
- If two :class: `Row ` objects have exactly the same columns and their
1122
- members are equal, they compare equal.
1145
+ Two row objects are equal if they have equal columns and equal members.
1123
1146
1124
1147
.. method :: keys
1125
1148
@@ -1618,8 +1641,10 @@ Using :mod:`sqlite3` efficiently
1618
1641
--------------------------------
1619
1642
1620
1643
1621
- Using shortcut methods
1622
- ^^^^^^^^^^^^^^^^^^^^^^
1644
+ .. _sqlite3-connection-shortcuts :
1645
+
1646
+ Using connection shortcut methods
1647
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1623
1648
1624
1649
Using the nonstandard :meth: `execute `, :meth: `executemany ` and
1625
1650
:meth: `executescript ` methods of the :class: `Connection ` object, your code can
0 commit comments