Python mysqldb返回插入的行,但mysql返回一个emptyset
我使用mysqldb插入一行:Python mysqldb返回插入的行,但mysql返回一个emptyset,python,mysql,mysql-python,Python,Mysql,Mysql Python,我使用mysqldb插入一行: def insertNewLog(self,uid,beginDate,endDate,logs): qry1 = """INSERT INTO logs (owner,createDate,endDate,log) VALUES (%s,%s,%s,%s); """ cursor = self.db.cursor() beginDate = int(time.mktime( beginDate.timetupl
def insertNewLog(self,uid,beginDate,endDate,logs):
qry1 = """INSERT INTO logs (owner,createDate,endDate,log) VALUES (%s,%s,%s,%s); """
cursor = self.db.cursor()
beginDate = int(time.mktime( beginDate.timetuple() ))
endDate = int(time.mktime( endDate.timetuple()))
print beginDate
print endDate
cursor.execute(qry1,(uid,beginDate,endDate,logs),)
print "inserted normally"
print "Number of rows inserted: %d" % cursor.rowcount
我得到这个输出:
1337720045
1337740625
inserted normally
Number of rows inserted: 1
然而,当我在mysql shell中对我的数据库进行选择时,我得到了“空集”。我检查了我的mysql日志,里面没有任何报告。我有点困惑 您可能应该在db连接上调用
commit()
。否则将回滚插入。您可能应该在db连接上调用commit()
。否则,将回滚镶件