You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try:
with con:
con.execute("insert into person(firstname) values (?)", ("Joe",))
except sqlite3.IntegrityError:
print "couldn't add Joe twice"
that will automatically commit upon success (though note that there are some places where we explicitly do not commit the DB) and roll back upon error.
The text was updated successfully, but these errors were encountered:
https://docs.python.org/2/library/sqlite3.html#using-the-connection-as-a-context-manager
This allows us to wrap queries in a block:
that will automatically commit upon success (though note that there are some places where we explicitly do not commit the DB) and roll back upon error.
The text was updated successfully, but these errors were encountered: