microsoft / microsoft/mssql-python

True async query execution

Offen
#9 19 Kommentare 24 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@sumitmsft arbeitet bereits daran.

Seit 03.3.2025.

area: api-compliance enhancement triage done
Vorherrschende Sprache
Python
Sterne
472
Forks
60
Ø Merge
2 T. 11 Std.
Gemergte PRs (30 T.)
36

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.