skillfed

aiomysql

MySQL driver for asyncio.

aiomysql v0.3.2 16.8M downloads/30d#1,140 on PyPI1,895
Permissive license MIT Active released

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 on this page — 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

aiomysql on PyPI

pip

pip install aiomysql

uv

uv add aiomysql

poetry

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 the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — PyMySQL
Maintenance actively maintained — 296 days since the last release
Last repo commit
First released
Downloads 16,758,493/month — #1,140 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: aiomysql-0.3.2-py3-none-any.whl

Keywords: mysql, mariadb, asyncio, aiomysql

Development Status :: 3 - AlphaEnvironment :: Web EnvironmentFramework :: AsyncIOIntended Audience :: DevelopersOperating System :: POSIXProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: DatabaseTopic :: Database :: Front-Ends

Tags

async mysql driverasyncio mysql clientnon-blocking mysql queriesasync database access pythonmysql with async awaitasyncio database driverasync mysql connection pool
async-iomysql-driverconnection-pooling

More Database packages