0

I have a list like this:

prices= ['$22,999', '$7,499', '$33,000', '$6,000', '$34,600', '$8,999', '$6,200', '$7,975']

I want to insert this list to database like this:

sql = "INSERT INTO abc (a) VALUES (%s)"
mycursor.executemany(sql, prices)

but I get error, why?

 ValueError: Could not process parameters
6
  • 4
    Can you show your error messages? Commented Nov 15, 2021 at 7:48
  • ValueError: Could not process parameters @Rizquuula Commented Nov 15, 2021 at 8:06
  • Does this answer your question? MySQL Connector could not process parameters Commented Nov 15, 2021 at 8:09
  • I think you must transform the prices to an array of tuples of one element. Commented Nov 15, 2021 at 8:15
  • You are trying to input string value into SQL, is your SQL column type is string or numeric? Commented Nov 15, 2021 at 8:20

1 Answer 1

0

Transform list to list of tuples :

pricesTuples = [(p,) for p in prices]
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.