True async query execution
@sumitmsft 已经在做这个了。
开始于 2025年3月3日。
评估
这个 Issue 还没有评估数据。
描述
Is your feature request related to a problem? Please describe.
Currently, mssql-python does not support true async execution, forcing developers to use thread-based workarounds (asyncio.to_thread() or aioodbc). This leads to performance limitations, increased memory usage, and suboptimal scalability in high-throughput applications, such as web servers and data processing pipelines.
For applications using FastAPI, Django Async, or AI/ML workloads, true async support is critical for handling multiple concurrent database operations efficiently. Without it, developers face blocking I/O that slows down event-driven applications.
Describe the solution you'd like
- Truly non-blocking I/O using
asyncio(asyncio.StreamReader/asyncio.StreamWriter). - Async query execution with
await conn.execute("SELECT ..."). - Streaming large result sets asynchronously using
async for row in cursor. - Better scalability for FastAPI, Django Async, and other async frameworks.
Example API:
async def stream_users():
conn = await asyncpg.connect(...)
async with conn.transaction(): # Ensures rollback on failure
async for row in conn.cursor("SELECT * FROM users"):
print(row) # Process each row asynchronously
await conn.close()
asyncio.run(stream_users())
### Describe alternatives you've considered
- asyncio.to_thread() → Still uses blocking I/O and threads, increasing overhead.
- aioodbc → Uses a thread pool, not true async, leading to performance bottlenecks.
- Custom Thread Management → Adds complexity and does not scale well under high concurrency.
### Additional context
- 主要语言
- Python
- 星标
- 473
- 派生
- 60
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 36
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/mssql-python 的其他 Issue
-
area: bulk-copy bug triage done
microsoft/mssql-python#750 · 4 条评论 · 已指派 1 人 ·
-
announcement
microsoft/mssql-python#748 · 已指派 1 人 ·
-
area: connectivity-auth bug triage needed
难度 4/5 3-5 天 新手友好度 62/100
microsoft/mssql-python#746 · 1 条评论 ·
-
area: data-types bug triage done
难度 4/5 3-5 天 新手友好度 48/100
microsoft/mssql-python#745 · 1 条评论 ·
-
area: packaging-platform bug dependency: external triage done
microsoft/mssql-python#685 · 2 条评论 · 已指派 1 人 ·
查看 microsoft/mssql-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
难度 2/5 1-3 小时 新手友好度 88/100
OpenHands/extensions#626 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
CSCfi/sd-search-api#39 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 68/100
StevenBlack/hosts#3255 ·