Run multiple times without modifying any line of code
cursor.execute(sql2)
1.AttributeError
'NoneType' object has no attribute 'read'
2.IndexError
index out of range
3.AttributeError
'NoneType' object has no attribute 'settimeout'
4.AssertionError
Protocol error, expecting EOF
5.OperationalError
(2014, 'Command Out of Sync')
6.InternalError
Packet sequence number wrong - got 1 expected 2
7.OSError
[Errno 9] Bad file descriptor
.......
def getPosition(connect,ID):
lock = threading.Lock()
sql2 = "SELECT district,region,community FROM Position WHERE ID = {0};".format(ID)
lock.acquire()
cursor = connect.cursor()
connect.ping(reconnect=True)
cursor.execute(sql2) #the setnece
ans = ""
try:
l = cursor.fetchone()
ans = l[0]+l[1]+l[2]
except Exception:
return False
finally:
lock.release()
return ans
I use the producer-consumer model to connect to the mysql database through pymysql