我使用的是Python MySQL连接器,我在数据库中插入了一条记录,它很成功。但在Python代码中,我如何知道它是否被插入?
“我的表”没有主键。
def insert(params) :
db_connection = Model.get_db_connection()
cursor = db_connection.cursor()
try :
cursor.execute("""INSERT INTO `User`(`UID`, `IP`) VALUES(%s,%s);""", (params))
db_connection.commit()
except :
db_connection.rollback()
Model.close_db(db_connection)
return result