--- id: aiomysql version: "0.3.2" license: MIT license_treatment: permissive maintenance: active --- # aiomysql — MySQL driver for asyncio. License: permissive · Maintenance: active · Downloads: 16.8M/mo ## What it is and what it does aiomysql is an async wrapper around PyMySQL that lets you execute MySQL queries without blocking your asyncio event loop. It reuses PyMySQL's connection logic and SQL parsing but replaces all blocking I/O calls with async equivalents, so you can use `await` and `async with` to manage connections, cursors, and queries. The API mirrors PyMySQL closely, making it familiar if you've used that library, and it includes optional SQLAlchemy integration ported from aiopg for ORM-style queries. You create a connection pool with `create_pool()`, acquire connections from it, and execute queries through cursors—all with `await`. It supports both raw SQL and SQLAlchemy table operations, and works across Python 3.9 through 3.13. The package is actively maintained, has no known vulnerabilities, and carries an MIT license. Use it for: - Build async web services (FastAPI, aiohttp) that query MySQL without blocking the event loop. - Write concurrent batch jobs that fetch or insert data into MySQL from multiple coroutines. - Integrate MySQL with SQLAlchemy in async frameworks using the `aiomysql.sa` module. - Handle high-concurrency scenarios where traditional blocking drivers would exhaust thread pools. - Migrate from aiopg to MySQL while preserving async/await patterns and similar API structure. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. aiomysql provides async/await access to MySQL databases by wrapping PyMySQL with asyncio support, letting you query MySQL non-blockingly from async Python code. Yes. aiomysql is a straightforward, low-friction async MySQL driver with active maintenance, no security issues, permissive licensing, and broad Python version support. Install it if you need non-blocking MySQL access in an asyncio application; the single dependency (PyMySQL) and pure-Python wheel keep setup simple. ## Install pip install aiomysql uv add aiomysql poetry add aiomysql ## Installing aiomysql Before you install: Low friction: pure Python wheel with a single runtime dependency (PyMySQL). Actively maintained with recent commits and a stable repository; marked Alpha but in use across a broad Python version range (3.9–3.13). License in practice: MIT license is permissive; you may use, modify, and distribute aiomysql with minimal restrictions, making it suitable for both open-source and commercial projects. Quickstart: import asyncio import aiomysql async def query(): async with aiomysql.create_pool(host='127.0.0.1', user='root', db='mysql') as pool: async with pool.acquire() as conn: async with conn.cursor() as cur: await cur.execute("SELECT 42;") result = await cur.fetchone() print(result) asyncio.run(query()) Requires a running MySQL server and valid connection credentials; Python 3.9 or later. Verify before relying: - Whether the Alpha status (Development Status :: 3) reflects active development or stable-but-unversioned API. - Performance characteristics compared to other async MySQL drivers in production workloads. - Compatibility with MariaDB versions beyond basic keyword mention. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 16.8M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags async mysql driver, asyncio mysql client, non-blocking mysql queries, async database access python, mysql with async await, asyncio database driver, async mysql connection pool, async-io, mysql-driver, connection-pooling [View on SkillFed](https://skillfed.io/packages/aiomysql) · [View on PyPI](https://pypi.org/project/aiomysql/)