0
在当前场景中result2不会被执行,直到result1完成其执行。我想执行select * from Test1和select * from Test2异步.result2不应该等待结果1完成它的执行。最后同时发送两个结果集给客户端。如何在django中异步执行postgre查询
def fetchQueryData(request):
cur=connection.cursor()
cur.execute("select * from Test1")
result1=cur.fetchall()
json1=result1[0][0]
cur.execute("select * from Test2")
result2=cur.fetchall()
json2=result2[0][0]
cur.close()
return JsonResponse([json1,json2])
此[博客文章](http://techspot.zzzeek.org/2015/02/15/asynchronous-python-and-databases/)可能对您有所帮助 – dahrens
django频道 –