PyMySQL
Pure Python MySQL Driver
Decision gist · record as of 2026-08-14
Yes. PyMySQL is a mature, actively maintained library with no known vulnerabilities, low installation friction, and a permissive MIT license. It is the right choice if you need pure-Python MySQL connectivity without compiled dependencies. Install it if you are building a Python application that must connect to MySQL or MariaDB and prefer or require a pure-Python driver.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or newer; a running MySQL or MariaDB server is also required.
- For sha256_password or caching_sha2_password authentication, install with the [rsa] extra; for MariaDB ed25519 authentication, use the [ed25519] extra.
- Installation is straightforward with no compiled dependencies—the wheel installs cleanly.
License · maintenance · safety
MIT (permissive) — PyMySQL is released under the MIT License, a permissive license that allows commercial and private use with minimal restrictions, making it suitable for most projects.
last release 2026-05-19 (87 days) · last repo commit 2026-08-05 · 7,845 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 95,672,299 downloads/mo, #355 on PyPI
Alternatives
Verify before relying
pip install PyMySQL
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()
connection.close()- Performance characteristics compared to other MySQL drivers (e.g., latency, throughput for large result sets)
- Whether the package supports connection pooling or if external pooling libraries are required
- Specific MariaDB versions tested and certified compatible
What it is and what it does
PyMySQL is a pure-Python implementation of a MySQL and MariaDB client that follows the DB-API 2.0 specification. It allows Python applications to connect to MySQL or MariaDB databases, execute queries, and retrieve results without requiring any compiled C extensions or external MySQL client libraries.
The package is designed for straightforward database connectivity in environments where a pure-Python solution is preferred or necessary. It supports both CPython 3.9+ and PyPy, handles parameterized queries to prevent SQL injection, and provides cursor-based access to query results. Optional extras enable advanced authentication methods (RSA-based password hashing and MariaDB ed25519) when needed.
Use it for
- Building web applications that need to query MySQL or MariaDB databases without system-level C dependencies
- Running Python database code in restricted environments (containers, serverless) where compiled extensions are unavailable
- Prototyping or scripting against MySQL/MariaDB when you want a lightweight, dependency-free driver
- Cross-platform Python projects targeting both CPython and PyPy interpreters
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
PyMySQL is a mature, actively maintained library with no known vulnerabilities, low installation friction, and a permissive MIT license. It is the right choice if you need pure-Python MySQL connectivity without compiled dependencies. Install it if you are building a Python application that must connect to MySQL or MariaDB and prefer or require a pure-Python driver.
Install
pymysql on PyPI
Before you install
Installation is straightforward with no compiled dependencies—the wheel installs cleanly. The package is actively maintained with a recent release and no known vulnerabilities, making it a low-friction choice for MySQL connectivity.
Requires Python 3.9 or newer; a running MySQL or MariaDB server is also required. For sha256_password or caching_sha2_password authentication, install with the [rsa] extra; for MariaDB ed25519 authentication, use the [ed25519] extra.
License in practice
PyMySQL is released under the MIT License, a permissive license that allows commercial and private use with minimal restrictions, making it suitable for most projects.
Quickstart
pip install PyMySQL
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()
connection.close()
Verify before relying
- Performance characteristics compared to other MySQL drivers (e.g., latency, throughput for large result sets)
- Whether the package supports connection pooling or if external pooling libraries are required
- Specific MariaDB versions tested and certified compatible
Package 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 87 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 95,672,299 / month, #355 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Database |
Evidence: pymysql-1.2.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “db-api mysql”
- PyMySQLPyMySQL is a pure-Python MySQL and MariaDB client library that…
- singlestoredbProvides a DB-API 2.0 compatible Python interface to SingleStore, a…
- aurora-data-apiA DB-API 2.0 compatible client for AWS Aurora Serverless that tunnels…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also django-mysql · mariadb · mysql-replication · mysqlclient · pymssql · mysql-connector-python · asyncmy2 · MySQL-python · asyncmy · pymgclient