擅长:python、mysql、java
<blockquote>
<p>I have two queries, I execute them in the mysql console I can view the results.</p>
</blockquote>
<p>但我只看到一个查询:</p>
<pre><code>import MySQLdb as mdb
con = mdb.connect(hostname, username, password, dbname)
cur = con.cursor()
count = cur.execute(query)
cur.close()
con.close()
</code></pre>
<p>我的<em>猜测</em>是<code>query</code>包含由一个半冒号分隔的<em>查询和</em>是<code>INSERT</code>语句吗?您可能需要使用<code>executemany()</code>。</p>
<p>见<a href="https://stackoverflow.com/questions/4615271/executing-several-sql-queries-with-mysqldb">Executing several SQL queries with MySQLdb</a></p>
<hr/>
<p>另一方面,如果您的两个查询都是<code>SELECT</code>语句(您说“I<em>请参阅</em>结果”),则我不确定您是否只能从对<code>execute()</code>的一个调用中获取这两个结果。无论如何,我认为那是一种糟糕的风格。</p>