0
import mysql.connector
mydb = mysql.connector.connect(
  host="10.0.72.17",
  user="admin",
  passwd="1qaz!QAZ",
  database="test"
)
mycursor = mydb.cursor()


sql = "INSERT INTO biage(kompaniis_saxeli) VALUES (%s)"
val = ('bane')
mycursor.execute(sql, val)
mycursor = mydb.cursor()

mydb.commit()

This is my python code , and i create column

kompaniis_saxeli varchar(225)

but when i try to run this code there is error

 raise ValueError("Could not process parameters")
ValueError: Could not process parameters
1
  • 1
    In Python, ('bane') is the same as 'bane', thus you're providing a string. You need to provide a tuple as the argument, and if you have only one value to pass, you can use val = ('bane',) (note the comma after the first element). Commented Nov 23, 2021 at 9:25

1 Answer 1

2

The python driver needs at least a 2 dimensional list for values

So use:

import mysql.connector
mydb = mysql.connector.connect(
  host="10.0.72.17",
  user="admin",
  passwd="1qaz!QAZ",
  database="test"
)
mycursor = mydb.cursor()


sql = "INSERT INTO biage(kompaniis_saxeli) VALUES (%s)"
val = ('bane',)
mycursor.execute(sql, val)
mycursor = mydb.cursor()

mydb.commit()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.