Python MySQL Driver using Cython
Project Links
Meta
Author: Yutaka Matsubara
Maintainer: Hajime Nakagami
Classifiers
Development Status
- 4 - Beta
Operating System
- OS Independent
Programming Language
- Python
- Python :: 3
Topic
- Database
- Database :: Front-Ends
- Software Development :: Libraries :: Python Modules
What’s CyMySQL
This package contains a python MySQL client library.
It is a fork project from PyMySQL https://pymysql.readthedocs.io/en/latest/.
CyMySQL is accerarated by Cython.
Documentation on the MySQL client/server protocol can be found here: http://dev.mysql.com/doc/internals/en/client-server-protocol.html
Requirements
Python 3.10+
MySQL 5.7 or higher, MariaDB
Installation
With cythonize
$ pip install cymysql
Or without cythonize
$ NO_CYTHON=1 pip install cymysql
Example
Python Database API Specification v2.0
https://peps.python.org/pep-0249/
import cymysql
conn = cymysql.connect(host='127.0.0.1', user='root', passwd='', db='database_name')
cur = conn.cursor()
cur.execute('select foo, bar from baz')
for r in cur.fetchall():
print(r[0], r[1])
asyncio
You can use asyncio to write the following.
Use connect
import asyncio
import cymysql
async def conn_example():
conn = await cymysql.aio.connect(
host="127.0.0.1",
user="root",
passwd="",
db="database_name",
)
cur = conn.cursor()
await cur.execute("SELECT 42")
print(await cur.fetchall())
asyncio.run(conn_example())
Use pool
import asyncio
import cymysql
async def pool_example(loop):
pool = await cymysql.aio.create_pool(
host="127.0.0.1",
user="root",
passwd="",
db="database_name",
loop=loop,
)
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 42")
print(await cur.fetchall())
pool.close()
await pool.wait_closed()
loop = asyncio.get_event_loop()
loop.run_until_complete(pool_example(loop))
loop.close()
1.1.2
Sep 19, 2026
1.1.1
Jul 11, 2025
1.1.0
Jun 21, 2025
1.0.10
May 10, 2025
1.0.9
May 09, 2025
1.0.8
Apr 16, 2025
1.0.7
Apr 12, 2025
1.0.6
Feb 14, 2025
1.0.5
Feb 08, 2025
1.0.4
Jan 23, 2025
1.0.3
Oct 10, 2024
1.0.2
Aug 26, 2024
1.0.1
Sep 21, 2023
1.0.0
Sep 16, 2023
0.9.20
Aug 14, 2023
0.9.19
Jul 30, 2023
0.9.18
Apr 07, 2021
0.9.17
Apr 07, 2021
0.9.16
Apr 07, 2021
0.9.15
Aug 14, 2020
0.9.14
Jul 20, 2019
0.9.13
Jan 10, 2019
0.9.12
Jul 07, 2018
0.9.11
Jun 29, 2018
0.9.10
May 23, 2018
0.9.9
May 18, 2018
0.9.8
May 14, 2018
0.9.7
May 06, 2018
0.9.6
May 05, 2018
0.9.5
May 03, 2018
0.9.4
Nov 19, 2017
0.9.3
Nov 18, 2017
0.9.2
Oct 28, 2017
0.9.1
Aug 11, 2017
0.9.0
Jun 10, 2017
0.8.9
Jun 03, 2016
0.8.8
Jun 01, 2016
0.8.7
May 04, 2016
0.8.6
Apr 18, 2016
0.8.5
Oct 02, 2015
0.8.4
Sep 28, 2015
0.8.3
Sep 25, 2015
0.8.2
Jul 21, 2015
0.8.1
Mar 25, 2015
0.8.0
Mar 04, 2015
0.7.9
Mar 02, 2015
0.7.8
Sep 29, 2014
0.7.7
Sep 22, 2014
0.7.6
Sep 11, 2014
0.7.5
Sep 03, 2014
0.7.4
Jul 14, 2014
0.7.3
Jun 03, 2014
0.7.2
Dec 14, 2013
0.7.1
Nov 10, 2013
0.7.0
Nov 05, 2013
0.6.8
Oct 27, 2013
0.6.7
Oct 09, 2013
0.6.6
Jul 17, 2013
0.6.5
Jul 14, 2013
0.6.4
Jul 11, 2013
0.6.3
Jul 09, 2013
0.6.2
Jul 06, 2013
0.6.1
Jul 04, 2013
0.6.0
Apr 20, 2013
0.5.5
Mar 12, 2013
0.5.4
Mar 02, 2013
0.5.3
Feb 23, 2013
0.5.2
Jan 05, 2013
0.5.1
Jan 03, 2013
0.5.0
Jan 01, 2013