0

I want to be able to iterate thru a list in python and insert each element in a separate column on a table in MySQL DB.

i have this syntax which i also found here :

 jobdata = [sampledata,sampledata1,sampledata2]

 params = ['?' for item in jobdata]
 sql   = 'INSERT INTO refactorBatch (runnum, hold, processtn) VALUES (%s);' % ','.join(params)
 cursor.execute(sql, list)
 cnx.commit()

But i am having this error:

File "C:\Python27\lib\site-packages\mysql\connector\cursor.py", line 355, in _process_params
    "Failed processing format-parameters; %s" % err)
mysql.connector.errors.ProgrammingError: Failed processing format-parameters; argument 2 to map() must support iteration

Did i miss something here?

Thank you!

1 Answer 1

2

Most likely, it is the line

cursor.execute(sql, list)

which is attempting to use the builtin list type as an argument.

Sign up to request clarification or add additional context in comments.

1 Comment

oh wow. thanks! got rid of the error. but another one came up @zachgates mysql.connector.errors.ProgrammingError: Wrong number of arguments during string formatting

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.