Reputation: 6891
I use mysqldb to insert a row:
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
I get this output:
1337720045
1337740625
inserted normally
Number of rows inserted: 1
However when I do a select on my database in mysql shell I get 'empty set'. I check my mysql logs and there is nothing reported in there. I'm a bit baffled.
Upvotes: 0
Views: 510
Reputation: 69042
you should probably call commit()
on your db connection. otherwise the insert is rolled back.
Upvotes: 5