【发布时间】:2014-07-18 08:01:49
【问题描述】:
是否可以从 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')
【问题讨论】:
标签: python sql-server asynchronous python-3.4 python-asyncio