當(dāng)我運(yùn)行這個(gè)函數(shù)時(shí)發(fā)生了一些錯(cuò)誤,但我不知道出了什么問(wèn)題。def insertVariblesIntoTable(newepc, newtimestamp): try: connection = mysql.connector.connect(host='localhost', database='myDB', user='root', password='root') cursor = connection.cursor() mySql_insert_query = """INSERT INTO myTB(epc,time_stamp) SELECT newepc,newtimestamp FROM dual WHERE NOT EXISTS (SELECT * FROM myTB WHERE epc=newepc AND time_stamp>NOW()-INTERVAL 1 MINUTE )""" cursor.execute(mySql_insert_query) connection.commit() print("Record inserted successfully into myTB table") except mysql.connector.Error as error: print("Failed to insert into MySQL table {}".format(error)) finally: if (connection.is_connected()): cursor.close() connection.close() # print("MySQL connection is closed")錯(cuò)誤:無(wú)法插入 MySQL 表 1054 (42S22):“字段列表”中的未知列“newepc”
通過(guò) select ... where ... 命令使用 python.connector 時(shí)出錯(cuò)
胡說(shuō)叔叔
2023-05-09 10:11:36