SQL插入查询既不起作用也不显示任何错误

时间:2019-04-11 19:28:30

标签: python mysql

我正在使用查询mycursor.execute("insert into adb (date, lecture) values (%s,%s)", f_date, coun)

在表中插入(日期和整数)值

该值未插入,并且将打印输出作为-1记录插入

coun=0
mycursor = mydb.cursor()
mycursor.execute("Select count(*) from adb") 
myresult = mycursor.fetchone()
for a in myresult:
    coun = int(a)
coun=coun+1
now = datetime.datetime.now()
f_date = now.strftime('%Y-%m-%d')
mycursor.execute("insert into adb (date, lecture) values (%s,%s)", f_date, coun)
mydb.commit()
print(mycursor.rowcount, "record inserted.")

0 个答案:

没有答案