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
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 278 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  Failed attempts to load Microsoft Appstore Python DLLs piyushd 0 394 Oct-31-2023, 10:43 AM
Last Post: piyushd
  When does Python detect Errors? stamp1t 1 401 Oct-21-2023, 05:53 PM
Last Post: deanhystad
  Mysql and mysql.connector error lostintime 2 612 Oct-03-2023, 10:25 PM
Last Post: lostintime
  Mysql error message: Lost connection to MySQL server during query tomtom 6 15,684 Feb-09-2022, 09:55 AM
Last Post: ibreeden
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 6,574 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning
  Mysql. Not all parameters were used in the SQL statement cybertooth 5 18,352 Oct-14-2021, 05:01 AM
Last Post: cybertooth
  Program stuck at mysql.connector.connect zazas321 1 2,040 Jul-29-2021, 10:49 AM
Last Post: zazas321
  MYSQL.CONNECTOR ERROR DB1 8 3,776 Jul-23-2021, 03:31 AM
Last Post: DB1
  string.format() suddenly causing errors with google drive API zwitrader 0 1,734 Jun-28-2021, 11:38 PM
Last Post: zwitrader

Forum Jump:

User Panel Messages

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