【发布时间】:2013-10-03 11:33:58
【问题描述】:
我正在使用 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
【问题讨论】:
标签: python mysql mysql-connector