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?
Larz60+ write Jan-18-2022, 02:45 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
You need to fix indentation and post in python tags. Please read above link.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
You need to fix indentation and post in python tags. Please read above link.