Is it possible to perform asynchronous queries against Microsoft SQL Server from Python (3.4), i.e. in the context of an asyncio event loop?
The following is a skeleton asyncio program, where the (async) SQL query should be fitted into the do_it function:
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')
For now there is only PostgreSQL native asyncio support via aiopg library.
But you can run synchronous calls to MSSQL by loop.run_in_executor().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With