mysql - python still can't insert into database -
i want insert data mysql database still can't, here code:
import ue9 d = ue9.ue9() import datetime time import gmtime, strftime import mysqldb timee = "%y-%m-%d %h:%m:%s" noww = strftime(timee, gmtime()) print noww db = mysqldb.connect("localhost","root","root","temperature") cursor = db.cursor() sql = ("insert mydate(datenow) values(%s)",(noww)) try: cursor.execute(sql) db.commit() except: db.rollback() db.close()
but still can't connect database can me ?
you miss comma in list of values:
sql = ("insert mydate(datenow) values(%s)",(noww,))
Comments
Post a Comment