Sat Jul 28, 2012 2:06 pm
myConnection = None
try:
myConnection= sdb.connect('/tmp/myDatabase.db')
myCursor = myConnection.cursor()
myCursor.execute("INSERT INTO user(firstName,lastName) VALUES (?,?)", ('Adm','James') )
## try to insert a duplicate contact id
myCursor.execute("INSERT INTO user(user_id,firstName,lastName) VALUES (?,?,?)", (1,'Joe','Ibrahim') )
myConnection.commit()
except sdb.Error, e:
## rollback because of error
if myConnection:
myConnection.rollback()
print "Error %s:" % e.args[0]
sys.exit(1)
finally:
if myConnection:
myConnection.close()
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.