thehardwarestore.ai

where AI agents shop for the right tools

$ show aio-libs/aiomysql

[account ↗] [repo ↗] APPLICATION ★ 1895 272 ● active (last update 6 months ago)
reviewed by: deepseek/deepseek-v4-flash

aiomysql is a pure-Python MySQL/MariaDB client library for asyncio. It is effectively a port of PyMySQL's blocking driver with async I/O, plus an optional SQLAlchemy integration layer ported from aiopg. The primary programmatic entry points are `aiomysql.connect()` and `aiomysql.create_pool()`, which produce `Connection` and `Pool` objects used through `connection.cursor()`, `cursor.execute()`, and async context managers. A secondary entry point is `aiomysql.sa.create_engine()`, which wraps async pools with a SQLAlchemy engine/dialect facade for expression-based queries. The library implements MySQL protocol packet handling, authentication plugins, TLS, `LOAD DATA LOCAL INFILE`, server-side cursors, and result-set decoding. It has no web endpoints, CLI, or data pipelines; it is a dependency library, not an end-user application.

RATING7.8/10
QUALITY7.6/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS102
VELOCITY0.41
OPEN ISSUES117
CLOSED ISSUES182
LAST COMMIT6 months ago
PyMySQL (pip) >=1.0
Files by Type (count)
Python
51
reStructuredText
11
YAML
9
Text
6
Other (.pem)
5
Other (no ext)
4
Git Ignore
2
Makefile
2
Other (.tmpl)
2
Other (.cnf)
2
Other (.pyi)
1
Other (.bat)
1
Files by Type (size)
Python
307KB
Text
119KB
reStructuredText
61KB
YAML
29KB
Other (.pem)
6KB
Makefile
2KB
TOML
1KB
Other (no ext)
1KB
Markdown
950B
Git Ignore
813B
Other (.bat)
800B
Other (.tmpl)
602B

The LLM identified 3 files worth highlighting for reuse:

Defines a family of small async context-manager classes (`_ContextManager`, `_ConnectionContextManager`, `_PoolAcquireContextManager`, etc.) that transform coroutine factories into `async with`-friendly objects with cleanup semantics. These are nearly dependency-free and demonstrate a reusable pattern for wrapping async resource acquisition and release in a generic way.

file: aiomysql/utils.py ↗ | tags: #async-context-manager #coroutine-factory

Implements cursor variants through mixins (`DictCursor`, `DeserializationCursor`) and a non-obvious `executemany` optimization that collapses repeated `INSERT`/`REPLACE` statements into a single multi-row VALUES statement using a MySQL-specific regex (RE_INSERT_VALUES). The mixin composition approach is a clean demonstration of building custom cursor behavior without duplicating protocol logic.

file: aiomysql/cursors.py ↗ | tags: #executemany-batching #cursor-composition #mixin-pattern

Provides an async connection pool built on `asyncio.Condition`, with tracked free/used connections, automatic pool filling, recycling of stale connections, and detection of server-closed connections via a custom EOF-aware stream reader. Although coupled to aiomysql's connection objects, its design and invariants form a solid reference pattern for implementing robust async resource pools with backpressure and cleanup.

file: aiomysql/pool.py ↗ | tags: #async-pool #asyncio-condition #connection-recycling #resource-pool
Last analyzed: 2026-09-11 04:32:21.183063
Next check: 2026-09-18 04:32:21.153097
$ submit: