MySQL Forums
Forum List  »  Connector/Python

Multiple insert statements using execute(multi=True)
Posted by: Mythri Manjunath
Date: December 11, 2017 06:59AM

I have a string constructed with multiple insert statements and insert statement with values given in multiple-row syntax. Is it possible to specify multiple insert statements along with values given by multiple row syntax for execute(multi=true) in mysql-connector-python? For. e.g below is the string concatenated with the insert statements, first statement with multiple row values:

operation = 'INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9)(11,22,33),(44,55,66),(77,88,99);
INSERT INTO tb2_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
INSERT INTO tbl1_name (col1,col2) VALUES(col2*2,15);
INSERT INTO tbl1_name (col1,col2) VALUES(15,col1*2);
INSERT INTO tbl2_name (col1,col2) VALUES(col2*2,15);
INSERT INTO tbl2_name (col1,col2) VALUES(15,col1*2);'
for result in cursor.execute(operation, multi=True):
print reslut.row_count

Options: ReplyQuote


Subject
Written By
Posted
Multiple insert statements using execute(multi=True)
December 11, 2017 06:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.