PyMySQL
Pure Python MySQL Driver
Install
pymysql on PyPI
pip
pip install pymysqluv
uv add pymysqlpoetry
poetry add pymysqlPackage facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 86 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: pymysql-1.2.0-py3-none-any.whl
Keywords: MySQL
About PyMySQL
from the package's own PyPI description — quoted content, verbatim
Documentation Status (image) codecov (image) Ask DeepWiki (image)
PyMySQL
This package contains a pure-Python MySQL and MariaDB client library, based on PEP 249.
Requirements
- Python -- one of the following:
- CPython : 3.9 and newer
- PyPy : Latest 3.x version
- MySQL Server -- one of the following:
- MySQL LTS versions
- MariaDB LTS versions
Installation
Package is uploaded on PyPI.
You can install it with pip:
$ python3 -m pip install PyMySQL
To use "sha256_password" or "caching_sha2_password" for authenticate, you need to install additional dependency:
$ python3 -m pip install PyMySQL[rsa]
To use MariaDB's "ed25519" authentication method, you need to install additional dependency:
$...
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
Pure-Python MySQL and MariaDB client library implementing PEP 249, enabling direct database connections without compiled dependencies.
Low install friction with no runtime dependencies; actively maintained with recent commits and 7845 repository stars. Supports Python 3.9+ on CPython and PyPy.
MIT license permits commercial and private use with minimal restrictions, making it suitable for most projects.
Usage
import pymysql.cursors
connection = pymysql.connect(host='localhost',
user='user',
password='passwd',
database='db')
with connection.cursor() as cursor:
cursor.execute("SELECT * FROM users")
result = cursor.fetchone()
Requires MySQL Server (LTS) or MariaDB (LTS) running and accessible; Python 3.9 or newer required. Optional: install PyMySQL[rsa] for sha256_password/caching_sha2_password or PyMySQL[ed25519] for MariaDB ed25519 auth.
Verdict: Stable, actively maintained pure-Python MySQL driver with no runtime dependencies and permissive MIT licensing. Zero known vulnerabilities and top-1000 popularity make it a reliable choice for Python-to-MySQL connectivity.
Needs verification
- Performance characteristics compared to compiled alternatives (e.g., mysqlclient) for high-throughput scenarios
- Whether optional dependencies (rsa, ed25519) are pre-installed or require explicit installation for those auth methods
Similar packages
copyleft · top 1,000 on PyPI
mysqlclientcopyleft · top 1,000 on PyPI
oracledbunclear · top 1,000 on PyPI
pymssqlcopyleft · top 1,000 on PyPI
pyodbcpermissive · top 1,000 on PyPI
PyAthenapermissive · top 1,000 on PyPI
tzdatapermissive · top 100 on PyPI
redshift-connectorpermissive · top 1,000 on PyPI
pg8000permissive · top 1,000 on PyPI
charset-normalizerpermissive · top 100 on PyPI