为什么不在表中插入记录?

2024-09-27 07:21:20 发布

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

想用python将记录插入mysql,但只插入了上传日期。mysql连接已建立UserID1、link、desc、tag是文本变量,用于存储tkinter入口框中键入的字符串。请帮忙

userID1_info = userID1.get()
link_info = link.get()
desc_info = desc.get()
tag_info = tag.get()
cursor1 =  mycon.cursor()

now = datetime.now()
upload_date = now.strftime("%Y/%m/%d %H:%M:%S")

upload_query = "INSERT INTO link_manager(UserID, Links, Description, Tag, date_time) \
                VALUES ('{}','{}','{}','{}','{}')".format(userID1_info, link_info, desc_info, tag_info, upload_date)
cursor1.execute(upload_query)
mycon.commit(

)

运行程序时没有返回任何错误或异常。 数据确实会被插入,但在mysql表中只有upload\u日期和其他日期留空


Tags: infogetdatetag记录mysqllinkquery

热门问题