A fast asyncio MySQL driver
Project description
asyncmy - A fast asyncio MySQL driver
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.
License
This project is licensed under the Apache-2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asyncmy-0.1.2.tar.gz
(42.8 kB
view hashes)
Built Distribution
Close
Hashes for asyncmy-0.1.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c08ee81eabe48380a917a6a23a2dc1820d7d8b4570dce8104ac19b8557f330a2 |
|
MD5 | c9f0473491a999675e3e2261254bedc3 |
|
BLAKE2b-256 | 03e2efa427b63a02f059694d23a30c3b7e83252f025fcab7b83c70be22b01412 |