This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sqlite3 doc fix
Type: Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: comcol, nnorwitz
Priority: normal Keywords:

Created on 2007-06-17 15:08 by comcol, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg32355 - (view) Author: Mark Carter (comcol) Date: 2007-06-17 15:08
I ran the example given at
http://docs.python.org/lib/module-sqlite3.html
but it didn't affect the database because no commit() was made. This is a "gotcha" that will affect others, too. I recommend appending the example:

---begin
conn = sqlite3.connect('/tmp/example')
# ...
c = conn.cursor()

# Create table
c.execute('''create table stocks
(date text, trans text, symbol text,
 qty real, price real)''')

# Insert a row of data
c.execute("""insert into stocks
          values ('2006-01-05','BUY','RHAT',100,35.14)""")
---end

with the lines:

# commit the changes, and close out
c.close()
conn.commit() # make the changes "stick"
conn.close()
msg32356 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-06-17 18:50
Thanks for the report.  I updated the example and tested it.  I did a slightly different change by doing the commit first and optionally closing the cursor.

Committed revision 56009.
Committed revision 56010. (2.5)
History
Date User Action Args
2022-04-11 14:56:25adminsetgithub: 45102
2007-06-17 15:08:18comcolcreate