Skip to main content

asyncmy - A fast asyncio MySQL driver

image image pypi ci

Introduction

asyncmy is a fast asyncio MySQL driver, which reuse most of pymysql and rewrite core with cython to speedup.

Benchmark

The result comes from benchmark, we can know asyncmy performs well when compared to other drivers.

Install

Just install from pypi:

> pip install asyncmy

Usage

Use connect

from asyncmy import connect
from asyncmy.cursors import DictCursor
import asyncio


async def run():
    conn = await connect()
    async with conn.cursor(cursor=DictCursor) as cursor:
        await cursor.execute("create database if not exists test")
        await cursor.execute(
            """CREATE TABLE if not exists test.asyncmy
    (
        `id`       int primary key auto_increment,
        `decimal`  decimal(10, 2),
        `date`     date,
        `datetime` datetime,
        `float`    float,
        `string`   varchar(200),
        `tinyint`  tinyint
    )"""
        )


if __name__ == '__main__':
    asyncio.run(run())

Use pool

import asyncmy
import asyncio


async def run():
    pool = await asyncmy.create_pool()
    async with pool.acquire() as conn:
        async with conn.cursor() as cursor:
            await cursor.execute("SELECT 1")
            ret = await cursor.fetchone()
            assert ret == (1,)


if __name__ == '__main__':
    asyncio.run(run())

ThanksTo

  • pymysql, a pure python MySQL client.
  • aiomysql, a library for accessing a MySQL database from the asyncio.

License

This project is licensed under the Apache-2.0 License.

Metadata

Release files for asyncmy 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncmy 0.1.3
File Size Uploaded
asyncmy-0.1.3.tar.gz 43.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncmy 0.1.3
File Interpreter ABI Platform
asyncmy-0.1.3-cp39-cp39-manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details

Total release size: 3.2 MB

Release files / asyncmy-0.1.3.tar.gz

Download URL asyncmy-0.1.3.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5d5a3b0fa090baeae1e606d0385eccd82cb2459771ac96ce82e90e86822af961
BLAKE2b-256 checksum
How to use checksums
f0a14299c754fe3399dbb43f4d4656a491dc0c45e77865cab0bbe7d5f64d7ed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

Release files / asyncmy-0.1.3-cp39-cp39-manylinux2014_x86_64.whl

Download URL asyncmy-0.1.3-cp39-cp39-manylinux2014_x86_64.whl
Size 3.1 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
cefcefb883dc919e81130d7b7d3b5fbe6a0962fda4ef6d25beda4146b6b1e9e0
BLAKE2b-256 checksum
How to use checksums
ad05ea8633e734cf647c22362a1bf3863ea45080b69227f9a2088f1171c31188
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page