我写了一个Python程序是这样应该在多线程模式下运行:Python和sqlite3.ProgrammingError:递归使用游标不允许
def Func(host,cursor,db):
cursor.execute('''SELECT If_index, Username, Version, Community, Ip_traff FROM HOST WHERE
Hostname = ?''',(host,))
#do something
#--- Main ---
db = sqlite3.connect(os.getcwd()+'\HOST', check_same_thread = False) #opendatabase
cursor = db.cursor() #generate a cursor
for ii in range(len(host)): #host is a list of ipaddress
#for each host i want generate a thread
thr = threading.Thread(target = Func, args=(host[ii],cursor,db)
thr.start()
我收到sqlite3.ProgrammingError:递归使用游标不允许的。在这种情况下,我如何管理sqlite3的递归游标? 非常感谢 保罗
为什么你不给每个线程自己的光标? – 2014-10-29 13:14:18