是否可以从 Python (3.4) 对 Microsoft SQL Server 执行异步查询,即在asyncio事件循环的上下文中?
以下是一个骨架 asyncio 程序,其中 (async) SQL 查询应适合该do_it
函数:
import asyncio
import contextlib
@asyncio.coroutine
def do_it():
# TODO: Make an asynchronous MS SQL query, but how??
fut = asyncio.Future()
fut.set_result(None)
return fut
with contextlib.closing(asyncio.SelectorEventLoop()) as loop:
asyncio.set_event_loop(loop)
loop.run_until_complete(do_it())
print('Finished')