Python Forum
mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python
#1
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.

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.
Reply
#2
Sorry for my bad question asking.
I edited it. I already post my all code and error :(
Reply
#3
Did you mean to put the item that is currently being iterated over from output and not output itself in the following line.
val = (output, dt_string)
Reply
#4
I want to insert this line into my db.
So i want to insert the output

output = wmi.query("SELECT * FROM Win32_Processor")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  image processing with opencv-python and Tesseract OCR marchellopl 4 157 Feb-15-2026, 12:27 AM
Last Post: Pedroski55
  How to optimize the speed of processing large JSON files in Python without using too sophia2005 3 963 Aug-02-2025, 03:25 PM
Last Post: snippsat
  MariaDB Connector/Python; version mismatch shopgeek 1 1,519 Feb-24-2025, 05:06 AM
Last Post: from1991
  Sudden Extremely Slow / Failed Python Imports bmccollum 1 2,578 Aug-20-2024, 02:09 PM
Last Post: DeaD_EyE
  Linux, Python, C ++, Brain2 and errors. PiotrBujakowski 0 1,475 Jun-24-2024, 03:41 PM
Last Post: PiotrBujakowski
Question No disconnect method for snowflake.connector ? Calab 0 1,359 Jun-11-2024, 09:42 PM
Last Post: Calab
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 1,941 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  Failed attempts to load Microsoft Appstore Python DLLs piyushd 0 2,253 Oct-31-2023, 10:43 AM
Last Post: piyushd
  When does Python detect Errors? stamp1t 1 3,639 Oct-21-2023, 05:53 PM
Last Post: deanhystad
  Mysql and mysql.connector error lostintime 2 2,562 Oct-03-2023, 10:25 PM
Last Post: lostintime

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020