封装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.0.tar.gz
(5.0 kB
view details)
Built Distribution
File details
Details for the file asmysql-0.1.0.tar.gz
.
File metadata
- Download URL: asmysql-0.1.0.tar.gz
- Upload date:
- Size: 5.0 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 | 9f718a9644d8d856b5717ec66bea3ce30be374a2f2831c087fa1fa120f2c660b |
|
MD5 | 8071ee7915666ec7f6a4d6aa63669b12 |
|
BLAKE2b-256 | b90c13e915342e2cc38ec2a666a116ac14c299c19cf5e1a8b240d48b9fd01430 |
File details
Details for the file asmysql-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: asmysql-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 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 | 523effcf35c97bb56ae0e71a4219b4d04a80b7ed196dcc9ff8a9c8e879340065 |
|
MD5 | e62099e6621e7a36e6db6a8ed2b38ee3 |
|
BLAKE2b-256 | 2ab1929dc0822e824db90bcad683f2af49bee682f769044b02455bcfc5b42d8c |