mysql-connector-python:execute(multi = true),带有多个insert语句+多行语法

时间:2017-11-22 15:28:09

标签: python mysql sql mysql-connector mysql-connector-python

我有一个用多个insert语句和insert语句构造的字符串,其中的值以多行语法给出。是否可以在mysql-connector-python中为execute(multi = true)指定多个insert语句以及多行语法给出的值?对于。例如,下面是与insert语句连接的字符串,第一个语句带有多个行值:

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

0 个答案:

没有答案