封装aiomysql的异步mysql客户端引擎。
Project description
asmysql
Introduction
asmysql is a library for using the MySQL asynchronous client, which is a wrapper for aiomysql.
Features
- Code supports type annotations.
- Very easy to use, simply inherit the AsMysql class for logical development.
- Supports automatic management of the MySQL connection pool and reconnection mechanism.
- Automatically captures and handles MysqlError errors globally.
- Separates statement execution from data retrieval.
Install
# Python3.11+
pip install asmysql
Documentation
Quick Start
import asyncio
from asmysql import AsMysql
class TestAsMysql(AsMysql):
host = '127.0.0.1'
port = 3306
user = 'root'
password = 'pass'
async def get_users(self):
result = await self.client.execute('select user,authentication_string,host from mysql.user')
if result.err:
print(result.err)
else:
async for item in result.iterate():
print(item)
async def main():
mysql = await TestAsMysql()
await mysql.get_users()
asyncio.run(main())
More Usage
import asyncio
from asmysql import AsMysql
class TestAsMysql(AsMysql):
async def get_users(self):
result = await self.client.execute('select user,authentication_string,host from mysql.user')
if result.err:
print(result.err)
else:
return await result.fetch_all()
mysql = TestAsMysql(host='192.168.1.192', port=3306)
async def main():
await mysql.connect() # or: await mysql
print(await mysql.get_users())
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asmysql-0.1.1.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file asmysql-0.1.1.tar.gz
.
File metadata
- Download URL: asmysql-0.1.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Linux/6.1.0-kali9-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b08ce25e2a039b95ba032c680021f26afc794c40620ba2c68c22832e00213b8 |
|
MD5 | 4bded96c63f5b7689f67dfca9257413c |
|
BLAKE2b-256 | 2dee3cda947313ca7da0b437745cb4de73afa590d894a7a61230fa38c47ecd90 |
File details
Details for the file asmysql-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: asmysql-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Linux/6.1.0-kali9-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 019f5e21a403c82a6a72d465f9ded71e75b9581c9731cc4f94d0adb7d57b7e63 |
|
MD5 | eec0cbb7aee8f57fad21816cdbc822fc |
|
BLAKE2b-256 | 3fe3a5baf3b44effd66af080abdc5eb01d1f219cda7fe00d93a600c11b2d2ab7 |