Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. MySQL
  3. pymysql

pymysql

MITPythonv1.1.2

A pure-Python MySQL and MariaDB client library implementing the Python DB-API 2.0 specification.

Visit WebsiteGitHubGitHub
7.8k stars1.4k forks0 contributors

What is pymysql?

PyMySQL is a pure-Python client library for connecting to MySQL and MariaDB databases from Python applications. It implements the Python DB-API 2.0 specification (PEP 249), providing a standardized interface for executing SQL queries, managing transactions, and handling database connections. The library enables Python developers to interact with MySQL-compatible databases without requiring external C dependencies.

Target Audience

Python developers who need to connect their applications to MySQL or MariaDB databases, particularly those who prefer pure-Python solutions or work in environments where C extensions are problematic.

Value Proposition

PyMySQL offers a clean, dependency-free Python implementation that's easy to install and deploy across different platforms while maintaining full compatibility with MySQL and MariaDB features. Unlike some alternatives, it has no external C dependencies, making it more portable and simpler to manage in various deployment scenarios.

Overview

MySQL client library for Python

Use Cases

Best For

  • Python web applications that need MySQL/MariaDB database connectivity
  • Data analysis scripts requiring interaction with MySQL databases
  • Projects where pure-Python dependencies are preferred over C extensions
  • Educational environments teaching database programming with Python
  • Cross-platform applications that need consistent MySQL access
  • Quick prototyping with MySQL/MariaDB from Python

Not Ideal For

  • High-performance applications requiring maximum database throughput, where C-based clients like mysqlclient excel
  • Projects using Django ORM without configuration changes, as Django's default backend is optimized for mysqlclient
  • Environments where minimizing optional dependencies is critical, due to extra packages for modern authentication methods

Pros & Cons

Pros

Pure Python Simplicity

No external C dependencies make installation straightforward with 'pip install PyMySQL', ensuring cross-platform compatibility without compilation issues, as highlighted in the README's installation section.

Standards Compliance

Implements DB-API 2.0 (PEP 249), providing a consistent interface familiar to Python developers, which reduces learning curve and ensures interoperability with other database tools.

Broad Database Support

Compatible with both MySQL LTS versions and MariaDB LTS versions, offering flexibility in database choice without needing separate libraries, as specified in the requirements.

Modern Authentication

Supports sha256_password, caching_sha2_password, and MariaDB's ed25519 methods with optional dependencies, keeping up with security advancements in MySQL/MariaDB ecosystems.

Flexible Data Handling

Includes DictCursor for returning rows as dictionaries, making data access more intuitive for Python workflows, as demonstrated in the example code snippet.

Cons

Optional Dependency Complexity

For modern authentication methods like sha256_password or ed25519, additional packages (PyMySQL[rsa] or PyMySQL[ed25519]) must be installed, adding setup steps and potential dependency conflicts.

Performance Limitations

As a pure-Python implementation, it may not match the speed of C-based alternatives like mysqlclient in high-throughput scenarios, which could impact data-intensive applications.

Ecosystem Integration Challenges

Some Python frameworks and ORMs, such as Django, default to or are optimized for other drivers, requiring extra configuration and potentially lacking seamless integration out-of-the-box.

Limited Advanced Features

Lacks built-in connection pooling or some database-specific optimizations found in more mature drivers, necessitating manual implementation or third-party solutions for scalability.

Open Source Alternative To

pymysql is an open-source alternative to the following products:

M
MySQL Connector/Python

MySQL Connector/Python is a standardized database driver for Python that enables Python applications to connect to MySQL servers.

Frequently Asked Questions

Quick Stats

Stars7,831
Forks1,439
Contributors0
Open Issues17
Last commit2 days ago
CreatedSince 2011

Tags

#database-driver#pure-python#python#mariadb#mysql#mysql-client#database-connectivity#sql

Built With

P
Python

Links & Resources

Website

Included in

Python290.8kMySQL2.6k
Auto-fetched 1 day ago

Related Projects

go-sql-drivergo-sql-driver

Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package

Stars15,252
Forks2,332
Last commit3 days ago
redis-pyredis-py

Redis Python client

Stars13,522
Forks2,676
Last commit2 days ago
awesome-postgresawesome-postgres

A curated list of awesome PostgreSQL software, libraries, tools and resources, inspired by awesome-mysql

Stars11,852
Forks951
Last commit27 days ago
PyMongoPyMongo

PyMongo - the Official MongoDB Python driver

Stars4,341
Forks1,139
Last commit3 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub