我正在尝试在多个线程之间共享psycopg2连接。正如文档中提到的,每当我在新线程中使用共享连接时,我都会通过从共享连接创建新的游标对象来做到这一点。thread.start_new_thread(delete,(conn,)) while True: print i conn.commit()
运行之后,我会得到如
因此,API调用如下所示: conn = psycopg2.connect(...) # always the same database.cur.execute(command, [Json(data)])当连续调用两次时,此调用将导致错误(在“cur.execute”处):由于服务器一直在运行,所以我还可以在API调用"pg_u