Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

PyMySQL

> 数据库
Open source

MySQL client library for Python

7.8K stars0 likes0 views
WebsiteGitHub

About

MySQL client library for Python

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:

$ python3 -m pip install PyMySQL[ed25519]

Documentation

Documentation is available online: https://pymysql.readthedocs.io/

For support, please refer to the StackOverflow.

Example

The following examples make use of a simple table

sql
CREATE TABLE `users` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `email` varchar(255) COLLATE utf8_bin NOT NULL,
    `password` varchar(255) COLLATE utf8_bin NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
AUTO_INCREMENT=1 ;
…

This example will print:

python
{"password": "very-secret", "id": 1}

Resources

  • DB-API 2.0: https://www.python.org/dev/peps/pep-0249/
  • MySQL Reference Manuals: https://dev.mysql.com/doc/
  • Getting Help With MariaDB https://mariadb.com/kb/en/getting-help-with-mariadb/
  • MySQL client/server protocol: https://dev.mysql.com/doc/internals/en/client-server-protocol.html
  • "Connector" channel in MySQL Community Slack: https://lefred.be/mysql-community-on-slack/
  • PyMySQL mailing list: https://groups.google.com/forum/#!forum/pymysql-users

License

PyMySQL is released under the MIT License. See LICENSE for more information.

Issues· 16 open

View all issuesOpen on GitHub
  • #857

    Compression

    Priority-HighFeature RequestUpdated Sep 17, 2026
  • #376

    LoadLocalFile should be able to take file like object

    Updated Sep 17, 2026
  • #1252

    Change password encoding to utf-8

    Updated Jun 17, 2026
  • #1169

    Option to add a timeout for ping

    Updated May 29, 2026
  • #202

    Support prepared statement.

    Priority-LowUpdated Dec 3, 2024
  • #506

    New executemany() implementation supporting UPDATE query

    Feature RequestUpdated Sep 11, 2024
  • #297

    Add speedup module for CPython

    Updated May 23, 2023
  • #843

    cursor.mogrify_many()

    Feature RequestUpdated Jan 3, 2021
  • #789

    FEATURE REQUEST: Add ability to include table name for all returned column names/values

    Feature RequestUpdated Jul 18, 2020
  • #32

    Add display size field to descriptor tuple.

    Priority-LowUpdated Apr 28, 2019

> Tags

Pythonmysqlpython

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库