@@ -67,15 +67,28 @@ after restarting the Python interpreter::
6767   con = sqlite3.connect('example.db') 
6868   cur = con.cursor() 
6969
70- To retrieve data after executing a SELECT statement, either treat the cursor as
71- an :term: `iterator `, call the cursor's :meth: `~Cursor.fetchone ` method to
72- retrieve a single matching row, or call :meth: `~Cursor.fetchall ` to get a list
73- of the matching rows.
70+ At this point, our database only contains one row::
7471
75- This example uses the iterator form::
72+    >>> res = cur.execute('SELECT count(rowid) FROM stocks') 
73+    >>> print(res.fetchone()) 
74+    (1,) 
75+ 
76+ The result is a one-item :class: `tuple `:
77+ one row, with one column.
78+ Now, let us insert three more rows of data,
79+ using :meth: `~Cursor.executemany `::
80+ 
81+    >>> data = [ 
82+        ('2006-03-28', 'BUY', 'IBM', 1000, 45.0), 
83+        ('2006-04-05', 'BUY', 'MSFT', 1000, 72.0), 
84+        ('2006-04-06', 'SELL', 'IBM', 500, 53.0), 
85+    ] 
86+    >>> cur.executemany('INSERT INTO stocks VALUES(?, ?, ?, ?)', data) 
87+ 
88+ Then, retrieve the data by iterating over the result of a ``SELECT `` statement::
7689
7790   >>> for row in cur.execute('SELECT * FROM stocks ORDER BY price'): 
78-             print(row) 
91+    ...      print(row) 
7992
8093   ('2006-01-05', 'BUY', 'RHAT', 100, 35.14) 
8194   ('2006-03-28', 'BUY', 'IBM', 1000, 45.0) 
@@ -980,12 +993,14 @@ Cursor Objects
980993      :term: `iterator ` yielding parameters instead of a sequence.
981994      Uses the same implicit transaction handling as :meth: `~Cursor.execute `.
982995
983-       .. literalinclude :: ../includes/sqlite3/executemany_1.py 
984- 
985-       Here's a shorter example using a :term: `generator `:
986- 
987-       .. literalinclude :: ../includes/sqlite3/executemany_2.py 
996+       Example::
988997
998+           data = [ 
999+               ("row1",), 
1000+               ("row2",), 
1001+           ] 
1002+           # cur is an sqlite3.Cursor object 
1003+           cur.executemany("insert into t values(?)", data) 
9891004
9901005   .. method :: executescript(sql_script, /) 
9911006
0 commit comments