1

Trying to insert four columns and multiple rows with variables. The table in mysql has 8 columns in total.

Four columns to insert is as following:

report_type= tuple(("ada","asda","frfe","adaaa","adaddd","fdgg"))
request_id = tuple(("12532532","22532432","3253263","424323","243255","6234532"))
situation = tuple(['IN_PROGRESS_' ]* len(request_id)) 
country =tuple(['us']* len(request_id))

The module I'm using is pymysql, and python version is 2.7 inserting code is as following:

sqlstr ="INSERT into info_request(request_id,country,report_type,situation) VALUES(%s, %s, %s, %s)" 
cursor.execute(sqlstr, (request_id,country,report_type,situation))

These query supposed to be work, but It returns Internalerror: (1241, u'Operand should contain 1 column(s)') I searched on this error for the whole day, but still can't solve it. Please help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.