擅长:python、mysql、java
<p>您正在调用cursor.fetchall()两次。你不应该这么做。</p>
<p>更改:</p>
<pre><code>row = cursor.fetchall()
results = len(cursor.fetchall())
clientName, clientAddr, unLocker = row[1], row[2], row[3]
</code></pre>
<p>致:</p>
<pre><code>rows = cursor.fetchall()
results = len(rows)
if results > 0:
row = rows[0]
clientName, clientAddr, unLocker = row[1], row[2], row[3]
</code></pre>
<p>虽然这与您当前的问题无关,但您应该使用参数化查询:</p>
<pre><code>query = "SELECT * FROM sessionkeys WHERE clientName=?"
cursor.execute(query, (value1,))
</code></pre>