Sql insert查询既不工作也不显示任何

2024-09-25 02:35:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在插入(日期和时间);int)使用查询的表中的值:mycursor.execute("insert into adb (date, lecture) values (%s,%s)", f_date, coun)

未插入值(&A);打印输出为插入的-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.")

Tags: executedatetimedate时间nowintinsertvalues