我使用
更新用户表(sqlite3和Python)中的行def update_user_by_id(self,id,first_name,last_name,username,password,privilege,email):
'''Update user in table user based on id on passed parameters'''
try:
connection=sqlite3.connect(self.__path_users)
cursor=connection.cursor()
cursor.execute('''UPDATE user SET first_name=?,last_name=?,username=?,password=?,privilege=?,email=? where id=?''',first_name,last_name,username,password,privilege,email,id)
connection.commit()
connection.close()
print "Affected: %d", cursor.rowcount
except sqlite3.Error, e:
print "Ooops:", e.args[0]
但如何将其纳入交易?
答案 0 :(得分:1)
这已经是一个交易。当您致电connection.commit()
时,交易将被提交。如果您想将其回滚,请删除该行。