擅长:python、mysql、java
<p>查看MySQLCursor.execute()的文档。</p>
<p>它声称您可以传入一个<code>multi</code>参数,该参数允许您在一个字符串中运行多个查询。</p>
<blockquote>
<p>If multi is set to True, execute() is able to execute multiple
statements specified in the operation string.</p>
</blockquote>
<p><code>multi</code>是execute()调用的第二个可选参数:</p>
<pre><code>operation = 'SELECT 1; INSERT INTO t1 VALUES (); SELECT 2'
for result in cursor.execute(operation, multi=True):
</code></pre>