Jan-18-2022, 05:14 PM
Hi everyone. Im a newbie in python.
I have the code below. Im on ubuntu 18.04. the variable "output " is a json data in my code.
mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python 'list' cannot be converted to a MySQL type
How can i solve this error?
I have the code below. Im on ubuntu 18.04. the variable "output " is a json data in my code.
import wmi_client_wrapper as wmi import mysql.connector from mysql.connector.constants import ClientFlag from datetime import datetime import json exec(open("/etc/epp/SNMP/mysqlconnector.py").read()) wmi = wmi.WmiClientWrapper( username="Administrator", password="Ares4382)", host="192.168.1.240", ) output = wmi.query("SELECT * FROM Win32_Processor") #print(output) #y = json.dumps(output) #print(y) for item in output: sql = "INSERT INTO wmi_inventory (wmi_data) VALUES (%s, %s)" now = datetime.now() dt_string = now.strftime("%Y-%m-%d-%H:%M:%S") val = (output, dt_string) cursor.execute(sql, val) connection.commit()When i execute my code it gives me error
mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python 'list' cannot be converted to a MySQL type
How can i solve this error?