Skip to main content

封装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.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

asmysql-0.1.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file asmysql-0.1.2.tar.gz.

File metadata

  • Download URL: asmysql-0.1.2.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

Hashes for asmysql-0.1.2.tar.gz
Algorithm Hash digest
SHA256 48fec9da7d942790d38372dbb06069b7d4a481c5af117b0437055ec099274d0f
MD5 a6befaa50eb61d55371c2499e211836a
BLAKE2b-256 5f5e0805668446de208ec8934dbc0e239fa6093e240e09371cda0fd4d55358a9

See more details on using hashes here.

File details

Details for the file asmysql-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: asmysql-0.1.2-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

Hashes for asmysql-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9cb90bbd8753567ff5c042dc6d33b8350a06b577eba40c77428ea4b3bd72a1b0
MD5 587325b2c0b4acdc6a9efe8aca7b8e88
BLAKE2b-256 52829c566739a730e7e02c01d2a73828a643b06c136bda86472e208abcd29166

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page