Coder Social home page Coder Social logo

long2ice / asyncmy Goto Github PK

View Code? Open in Web Editor NEW
210.0 6.0 22.0 617 KB

A fast asyncio MySQL/MariaDB driver with replication protocol support

Home Page: https://github.com/long2ice/asyncmy

License: Apache License 2.0

Makefile 0.27% Python 52.39% Cython 47.34%
mysql asyncio cython connector replication binlog

asyncmy's Introduction

asyncmy - A fast asyncio MySQL/MariaDB driver

image image pypi ci

Introduction

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

Features

  • API compatible with aiomysql.
  • Faster by cython.
  • MySQL replication protocol support with asyncio.
  • Tested both MySQL and MariaDB in CI.

Benchmark

The result comes from benchmark.

The device is iMac Pro(2017) i9 3.6GHz 48G and MySQL version is 8.0.26.

benchmark

Conclusion

  • There is no doubt that mysqlclient is the fastest MySQL driver.
  • All kinds of drivers have a small gap except select.
  • asyncio could enhance insert.
  • asyncmy performs remarkable when compared to other drivers.

Install

pip install asyncmy

Installing on Windows

To install asyncmy on Windows, you need to install the tools needed to build it.

  1. Download Microsoft C++ Build Tools from https://visualstudio.microsoft.com/visual-cpp-build-tools/
  2. Run CMD as Admin (not required but recommended) and navigate to the folder when your installer is downloaded
  3. Installer executable should look like this vs_buildtools__XXXXXXXXX.XXXXXXXXXX.exe, it will be easier if you rename it to just vs_buildtools.exe
  4. Run this command (Make sure you have about 5-6GB of free storage)
vs_buildtools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
  1. Wait until the installation is finished
  2. After installation will finish, restart your computer
  3. Install asyncmy via PIP
pip install asyncmy

Now you can uninstall previously installed tools.

Usage

Use connect

asyncmy provides a way to connect to MySQL database with simple factory function asyncmy.connect(). Use this function if you want just one connection to the database, consider connection pool for multiple connections.

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

asyncmy provides connection pool as well as plain Connection objects.

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())

Replication

asyncmy supports MySQL replication protocol like python-mysql-replication, but powered by asyncio.

from asyncmy import connect
from asyncmy.replication import BinLogStream
import asyncio


async def run():
    conn = await connect()
    ctl_conn = await connect()

    stream = BinLogStream(
        conn,
        ctl_conn,
        1,
        master_log_file="binlog.000172",
        master_log_position=2235312,
        resume_stream=True,
        blocking=True,
    )
    async for event in stream:
        print(event)


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

ThanksTo

asyncmy is build on top of these awesome projects.

  • pymysql, a pure python MySQL client.
  • aiomysql, a library for accessing a MySQL database from the asyncio.
  • python-mysql-replication, pure Python Implementation of MySQL replication protocol build on top of PyMYSQL.

License

This project is licensed under the Apache-2.0 License.

asyncmy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

asyncmy's Issues

sudden loss of float precision for even very low numbers of significant digits in the 0.2.7 series

occurs as of 0.2.7rc6 and possibly earlier, is not in 0.2.5

import asyncmy
import asyncio


async def main():
    conn = await asyncmy.connect(
        user="scott", password="tiger", db="test", host="localhost"
    )
    cursor = conn.cursor()

    await cursor.execute("""DROP TABLE IF EXISTS t""")

    await cursor.execute(
        """
    CREATE TABLE  t (
	scale_value DOUBLE(15, 12)
)"""
    )

    dec_value = 45.7683
    await cursor.execute(
        "INSERT INTO t (scale_value) VALUES (%s)", [dec_value]
    )

    await cursor.execute("SELECT scale_value FROM t")
    row = await cursor.fetchone()

    assert row[0] == dec_value, row[0]


asyncio.run(main())

test fails with

AssertionError: 45.768299102783

no other MySQL or database driver loses precision on only four significant digits. 0.2.5 did not have this problem and was on par with other drivers.

Using SSCursor as default cursor when setting connect_args from SQLAlchemy

Hi,

I'm transposing this answer: https://stackoverflow.com/a/31413200/330867

from sqlalchemy import create_engine, MetaData
import MySQLdb.cursors
engine = create_engine('mysql://your:details@go/here', connect_args={'cursorclass': MySQLdb.cursors.SSCursor})

to AsyncMy, which I'm using, but I can't make it work:

from sqlalchemy.ext.asyncio import create_async_engine
from asyncmy.cursors import SSCursor
engine = create_async_engine('mysql+asyncmy://user:[email protected]/db', connect_args={'cursorclass': SSCursor})

I get the following error:

TypeError: connect() got an unexpected keyword argument 'cursorclass'

I tried changing it to cursor, and got the same error:

TypeError: connect() got an unexpected keyword argument 'cursor'

Is there a way to define which cursor to use?

Failing connection call

I have had #55 issue and after installing v0.2.7 I get this long traceback, when I try to run an entrypoint of my app.

# python3 main.py
Traceback (most recent call last):
  File "asyncmy/connection.pyx", line 521, in asyncmy.connection.Connection.connect
  File "asyncmy/connection.pyx", line 512, in asyncmy.connection.Connection.connect
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
    transport, _ = await loop.create_connection(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1084, in create_connection
    raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 3306), [Errno 99] Cannot assign requested address

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3361, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 578, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 276, in connect
    await_only(self.asyncmy.connect(*arg, **kw)),
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
    return current.driver.switch(awaitable)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
    value = await result
  File "asyncmy/connection.pyx", line 1299, in _connect
  File "asyncmy/connection.pyx", line 544, in connect
asyncmy.errors.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 3306), [Errno 99] Cannot assign requested address)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 320, in start_polling
    loop.run_until_complete(self._startup_polling())
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 377, in _startup_polling
    await callback(self.dispatcher)
  File "/src/periodical_tasks/notifications/boot.py", line 20, in on_startup
    await write_postmasters(session)
  File "/src/db/writers.py", line 23, in write_postmasters
    postmasters_in_base = [_.name for _ in await read_postmasters(session)]
  File "/src/db/readers.py", line 21, in read_postmasters
    result = await session.scalars(stmt)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/session.py", line 271, in scalars
    result = await self.execute(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/session.py", line 214, in execute
    result = await greenlet_spawn(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 126, in greenlet_spawn
    result = context.throw(*sys.exc_info())
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1713, in execute
    conn = self._connection_for_bind(bind)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1552, in _connection_for_bind
    return self._transaction._connection_for_bind(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 747, in _connection_for_bind
    conn = bind.connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/future/engine.py", line 406, in connect
    return super(Engine, self).connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3315, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3394, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3364, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2198, in _handle_dbapi_exception_noconnection
    util.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3361, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 578, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 276, in connect
    await_only(self.asyncmy.connect(*arg, **kw)),
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
    return current.driver.switch(awaitable)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
    value = await result
  File "asyncmy/connection.pyx", line 1299, in _connect
  File "asyncmy/connection.pyx", line 544, in connect
sqlalchemy.exc.OperationalError: (asyncmy.errors.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' (Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 3306), [Errno 99] Cannot assign requested address)")
(Background on this error at: https://sqlalche.me/e/14/e3q8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "asyncmy/connection.pyx", line 521, in asyncmy.connection.Connection.connect
  File "asyncmy/connection.pyx", line 512, in asyncmy.connection.Connection.connect
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.10/asyncio/streams.py", line 48, in open_connection
    transport, _ = await loop.create_connection(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1084, in create_connection
    raise OSError('Multiple exceptions: {}'.format(
OSError: Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 3306), [Errno 99] Cannot assign requested address

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3361, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 578, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 276, in connect
    await_only(self.asyncmy.connect(*arg, **kw)),
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
    return current.driver.switch(awaitable)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
    value = await result
  File "asyncmy/connection.pyx", line 1299, in _connect
  File "asyncmy/connection.pyx", line 544, in connect
asyncmy.errors.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 3306), [Errno 99] Cannot assign requested address)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "//main.py", line 39, in <module>
    main()
  File "//main.py", line 33, in main
    executor.start_polling(dispatcher=dp,
  File "/usr/local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 45, in start_polling
    executor.start_polling(
  File "/usr/local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 328, in start_polling
    loop.run_until_complete(self._shutdown_polling())
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 381, in _shutdown_polling
    await callback(self.dispatcher)
  File "/src/periodical_tasks/notifications/shutdown.py", line 15, in on_shutdown
    users = await read_users(session)
  File "/src/db/readers.py", line 10, in read_users
    result = await session.scalars(stmt)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/session.py", line 271, in scalars
    result = await self.execute(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/ext/asyncio/session.py", line 214, in execute
    result = await greenlet_spawn(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 126, in greenlet_spawn
    result = context.throw(*sys.exc_info())
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1713, in execute
    conn = self._connection_for_bind(bind)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1552, in _connection_for_bind
    return self._transaction._connection_for_bind(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 747, in _connection_for_bind
    conn = bind.connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/future/engine.py", line 406, in connect
    return super(Engine, self).connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3315, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3394, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3364, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2198, in _handle_dbapi_exception_noconnection
    util.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 3361, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 327, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 894, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 493, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 145, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 273, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 388, in __init__
    self.__connect()
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 690, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 686, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 578, in connect
    return dialect.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 598, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 276, in connect
    await_only(self.asyncmy.connect(*arg, **kw)),
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
    return current.driver.switch(awaitable)
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
    value = await result
  File "asyncmy/connection.pyx", line 1299, in _connect
  File "asyncmy/connection.pyx", line 544, in connect
sqlalchemy.exc.OperationalError: (asyncmy.errors.OperationalError) (2003, "Can't connect to MySQL server on 'localhost' (Multiple exceptions: [Errno 111] Connect call failed ('127.0.0.1', 3306), [Errno 99] Cannot assign requested address)")
(Background on this error at: https://sqlalche.me/e/14/e3q8)

I get the traceback in a docker container (python:3.10 image). The same command in Windows 10 runs my app properly, without any traceback. Before I faced #55, entrypoint started correctly in both environments (docker container and windows 10).

ModuleNotFoundError: No module named 'asyncmy' despite being installed

When trying to make revision with Alembic it gives error like this:

Traceback (most recent call last):                                                                                           
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\alembic.exe\__main__.py", line 7, in <module>
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alembic\config.py", line 590, in main
    CommandLine(prog=prog).main(argv=argv)
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alembic\config.py", line 584, in main
    self.run_cmd(cfg, options)
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alembic\config.py", line 561, in run_cmd
    fn(
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alembic\command.py", line 229, in revision
    script_directory.run_env()
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alembic\script\base.py", line 569, in run_env
    util.load_python_file(self.dir, "env.py")
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alembic\util\pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\alembic\util\pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "sql_app/migrations\env.py", line 11, in <module>
    from sql_app.database import Base
  File "H:\GitHub\Smart_yard_Backend_server\.\sql_app\database.py", line 9, in <module>
    engine = create_engine(
  File "<string>", line 2, in create_engine
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\util\deprecations.py", line 309, in warned
    return fn(*args, **kwargs)
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\engine\create.py", line 548, in create_engine
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "C:\Users\fagir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\sqlalchemy\dialects\mysql\asyncmy.py", line 291, in dbapi
    return AsyncAdapt_asyncmy_dbapi(__import__("asyncmy"))
ModuleNotFoundError: No module named 'asyncmy'

After that I found this repository and reinstalled it with steps needed on Windows, but nothing changed.
Using asyncmy with SQLAlchemy ORM mode

Error connecting via unix socket

I'm getting the following error when attempting to connect using a unix socket:

Traceback (most recent call last): File "asyncmy/connection.pyx", line 532, in asyncmy.connection.Connection.connect File "asyncmy/connection.pyx", line 408, in asyncmy.connection.Connection._set_nodelay File "/usr/local/lib/python3.9/asyncio/trsock.py", line 82, in setsockopt self._sock.setsockopt(*args, **kwargs) OSError: [Errno 95] Operation not supported

It looks like there's a call to set TCP_NODELAY on the socket regardless of whether it's a TCP or Unix socket:

self._set_nodelay(True)

connection.autocommit(False) not working as of 0.2.1

the following test case succeeds in 0.2.0, fails in 0.2.1, 0.2.2:

import asyncio

import asyncmy

async def main():

    conn = await asyncmy.connect(user="scott", password="tiger", database="test", host="localhost")

    await conn.autocommit(True)

    cursor = conn.cursor()

    await cursor.execute("SELECT @@autocommit;")

    assert await cursor.fetchone() == (1, )

    await cursor.close()

    # turn autocommit off
    await conn.autocommit(False)

    cursor = conn.cursor()

    await cursor.execute("SELECT @@autocommit;")

    assert await cursor.fetchone() == (0, )

    await cursor.close()

asyncio.run(main())

the second assertion fails:

$ python test3.py 
Traceback (most recent call last):
  File "/home/classic/dev/sqlalchemy/test3.py", line 30, in <module>
    asyncio.run(main())
  File "/usr/lib64/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/classic/dev/sqlalchemy/test3.py", line 26, in main
    assert await cursor.fetchone() == (0, )
AssertionError

how to format?

When i try to format

await cursor.execute("SELECT * FROM settings WHERE userid = %s", (author.id))

It appears that

line 147, in mogrify
    query = query % self._escape_args(args, conn)
  File "/usr/lib/python3.9/site-packages/asyncmy/cursors.py", line 126, in _escape_args
    return conn.escape(args)
  File "asyncmy/connection.pyx", line 409, in asyncmy.connection.Connection.escape
  File "asyncmy/converters.pyx", line 10, in asyncmy.converters.escape_item
  File "asyncmy/converters.pyx", line 25, in asyncmy.converters.escape_item
  File "asyncmy/converters.pyx", line 48, in asyncmy.converters.escape_int
OverflowError: Python int too large to convert to C long

The value I want to format is 18 digits, the column has data type BIGINT. And sometimes I also need to format 18 digit values โ€‹โ€‹for 3 primary keys.

asyncmy.connection now missing in 2.5.0 from docker pip install

Hello, all the sudden asyncmy is unable to find connection package when pip installed inside python3.9-alpine3.16. See below to reproduce:

Dockerfile

FROM python:3.9-alpine3.16

RUN pip install asyncmy==0.2.5
CMD /bin/bash ls

Build: docker build -t testing .

SSH: docker run --rm -it --entrypoint sh testing:latest

/ # python
>>> from asyncmy.connection import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/asyncmy/__init__.py", line 1, in <module>
    from .connection import Connection, connect  # noqa:F401
ModuleNotFoundError: No module named 'asyncmy.connection'

However:

pip install asyncmy==0.2.7rc4
/ # python
Python 3.9.16 (main, Jan 24 2023, 00:06:28)
[GCC 11.2.1 20220219] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from asyncmy.connection import *
>>>

Works fine. I see that rc4 and rc5 were released in pypi yesterday, and we are now experiencing this issue. Not sure if this is a coincidence. Any advice?

Thanks in advance.

0.2.1 fails with FastAPI 0.7.0 / Python 3.10/ sqlmodel / SQLAlchemy

A simple fastapi application using python 3.10, which works with aiomysql (albeit with a patch to remove the loop argument on connect) fails with asyncmy.

  File "asyncmy/connection.pyx", line 373, in rollback
  File "asyncmy/connection.pyx", line 336, in _read_ok_packet
  File "asyncmy/connection.pyx", line 588, in read_packet
sqlalchemy.exc.InternalError: (asyncmy.errors.InternalError) Packet sequence number wrong - got 17 expected 1

The same code fails with both 3.9 and 3.10 using v 0.2.1 but is okay with 0.2.0 on 3.9 (obviously 3.10 fails with 0.2.0 due to the loop issue fixed in 0.2.1).

So something in the 0.2.1 release is causing problems. Code is too long to paste but should be easy to replicate.

ValueError: could not convert string to float

Given this extremely simple example:

source_engine = create_async_engine(
    f"mysql+asyncmy://{user}:{password}@{host}:{port}/{database}?charset=utf8",
    echo=True)

handled_rows = 0
lower_bound = 1_000_000 * int(sys.argv[1])
upper_bound = 1_000_000 + lower_bound
async with source_engine.begin() as conn:
    async for row in await conn.stream(text(f"SELECT * FROM {table} WHERE {lower_bound} <= ID AND ID < {upper_bound};")):
        handled_rows += 1
        if handled_rows % 10000 == 0:
            logger.info(f"{lower_bound} - {upper_bound} handled {handled_rows}")

in a fresh venv with these dependencies:

asyncmy==0.2.5
greenlet==1.1.3.post0
SQLAlchemy==1.4.42

I sometimes get this ValueError:

2022-10-27 10:42:50,471 INFO sqlalchemy.engine.Engine ROLLBACK
2022-10-27 10:42:50,471 INFO MainThread - sqlalchemy.engine.Engine:1055 _rollback_impl -- ROLLBACK
Traceback (most recent call last):
  File "test.py", line 55, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "test.py", line 50, in main
    async for row in await conn.stream(text(f"SELECT * FROM {table} WHERE {lower_bound} <= ID AND ID < {upper_bound};")):
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/result.py", line 174, in __anext__
    row = await greenlet_spawn(self._onerow_getter, self)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 128, in greenlet_spawn
    result = context.switch(value)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 457, in onerow
    row = self._fetchone_impl()
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 1340, in _fetchone_impl
    return self._real_result._fetchone_impl(hard_close=hard_close)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1816, in _fetchone_impl
    return self.cursor_strategy.fetchone(self, self.cursor, hard_close)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1096, in fetchone
    self._buffer_rows(result, dbapi_cursor)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1068, in _buffer_rows
    self.handle_exception(result, dbapi_cursor, e)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 955, in handle_exception
    result.connection._handle_dbapi_exception(
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2128, in _handle_dbapi_exception
    util.raise_(exc_info[1], with_traceback=exc_info[2])
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1066, in _buffer_rows
    new_rows = dbapi_cursor.fetchmany(size)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 169, in fetchmany
    return self.await_(self._cursor.fetchmany(size=size))
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
    return current.driver.switch(awaitable)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
    value = await result
  File "asyncmy/cursors.pyx", line 515, in fetchmany
  File "asyncmy/cursors.pyx", line 482, in read_next
  File "asyncmy/connection.pyx", line 1116, in _read_rowdata_packet_unbuffered
  File "asyncmy/connection.pyx", line 1157, in asyncmy.connection.MySQLResult._read_row_from_packet
ValueError: could not convert string to float: '751>2402'

Any clue what might be happening?

ModuleNotFoundError: No module named 'asyncmy.connection'

Can't run on python 3.10, Mac OS m1 arm64

File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/asyncmy/init.py", line 1, in
from .connection import Connection, connect # noqa:F401
ModuleNotFoundError: No module named 'asyncmy.connection'

Test failures and errors on 32-bit platforms

Is asyncmy intentionally 64-bit-only? I encounter a number of test failures and errors on 32-bit platforms (i686 or armv7hl/armhfp).

============================= test session starts ==============================
platform linux -- Python 3.10.1, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /builddir/build/BUILD/asyncmy-0.2.3
plugins: asyncio-0.14.0
collected 13 items
tests/test_autocommit.py .                                               [  7%]
tests/test_connection.py ..                                              [ 23%]
tests/test_cursor.py ...FEEE                                             [ 76%]
tests/test_pool.py EEEE                                                  [100%]
==================================== ERRORS ====================================
________________________ ERROR at setup of test_delete _________________________
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
            raise self._exception
    
        if n == 0:
            return b''
    
        while len(self._buffer) < n:
            if self._eof:
                incomplete = bytes(self._buffer)
                self._buffer.clear()
                raise exceptions.IncompleteReadError(incomplete, n)
    
>           await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
func_name = 'readexactly'
    async def _wait_for_data(self, func_name):
        """Wait until feed_data() or feed_eof() is called.
    
        If stream was paused, automatically resume it.
        """
        # StreamReader uses a future to link the protocol feed_data() method
        # to a read coroutine. Running two read coroutines at the same time
        # would have an unexpected behaviour. It would not possible to know
        # which coroutine would get the next data.
        if self._waiter is not None:
            raise RuntimeError(
                f'{func_name}() called while another coroutine is '
                f'already waiting for incoming data')
    
        assert not self._eof, '_wait_for_data after EOF'
    
        # Waiting for data while paused will make deadlock, so prevent it.
        # This is essential for readexactly(n) for case when n > self._limit.
        if self._paused:
            self._paused = False
            self._transport.resume_reading()
    
        self._waiter = self._loop.create_future()
        try:
>           await self._waiter
/usr/lib/python3.10/asyncio/streams.py:502: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
During handling of the above exception, another exception occurred:
args = ()
kwargs = {'connection': <asyncmy.connection.Connection object at 0xf6573cb8>}
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
setup = <function pytest_fixture_setup.<locals>.wrapper.<locals>.setup at 0xf652a2f8>
    def wrapper(*args, **kwargs):
        loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs)
    
        async def setup():
            res = await coro(*args, **kwargs)
            return res
    
>       return loop.run_until_complete(setup())
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
    return future.result()
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:140: in setup
    res = await coro(*args, **kwargs)
conftest.py:61: in truncate_table
    await cursor.execute("truncate table test.asyncmy")
asyncmy/cursors.pyx:180: in execute
    ???
asyncmy/cursors.pyx:365: in _query
    ???
asyncmy/connection.pyx:455: in query
    ???
asyncmy/connection.pyx:636: in _read_query_result
    ???
asyncmy/connection.pyx:1023: in read
    ???
asyncmy/connection.pyx:578: in read_packet
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   asyncmy.errors.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')
asyncmy/connection.pyx:612: OperationalError
______________________ ERROR at setup of test_executemany ______________________
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
            raise self._exception
    
        if n == 0:
            return b''
    
        while len(self._buffer) < n:
            if self._eof:
                incomplete = bytes(self._buffer)
                self._buffer.clear()
                raise exceptions.IncompleteReadError(incomplete, n)
    
>           await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
func_name = 'readexactly'
    async def _wait_for_data(self, func_name):
        """Wait until feed_data() or feed_eof() is called.
    
        If stream was paused, automatically resume it.
        """
        # StreamReader uses a future to link the protocol feed_data() method
        # to a read coroutine. Running two read coroutines at the same time
        # would have an unexpected behaviour. It would not possible to know
        # which coroutine would get the next data.
        if self._waiter is not None:
            raise RuntimeError(
                f'{func_name}() called while another coroutine is '
                f'already waiting for incoming data')
    
        assert not self._eof, '_wait_for_data after EOF'
    
        # Waiting for data while paused will make deadlock, so prevent it.
        # This is essential for readexactly(n) for case when n > self._limit.
        if self._paused:
            self._paused = False
            self._transport.resume_reading()
    
        self._waiter = self._loop.create_future()
        try:
>           await self._waiter
/usr/lib/python3.10/asyncio/streams.py:502: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
During handling of the above exception, another exception occurred:
args = ()
kwargs = {'connection': <asyncmy.connection.Connection object at 0xf6573cb8>}
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
setup = <function pytest_fixture_setup.<locals>.wrapper.<locals>.setup at 0xf64dbd60>
    def wrapper(*args, **kwargs):
        loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs)
    
        async def setup():
            res = await coro(*args, **kwargs)
            return res
    
>       return loop.run_until_complete(setup())
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
    return future.result()
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:140: in setup
    res = await coro(*args, **kwargs)
conftest.py:61: in truncate_table
    await cursor.execute("truncate table test.asyncmy")
asyncmy/cursors.pyx:180: in execute
    ???
asyncmy/cursors.pyx:365: in _query
    ???
asyncmy/connection.pyx:455: in query
    ???
asyncmy/connection.pyx:636: in _read_query_result
    ???
asyncmy/connection.pyx:1023: in read
    ???
asyncmy/connection.pyx:578: in read_packet
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   asyncmy.errors.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')
asyncmy/connection.pyx:612: OperationalError
_______________________ ERROR at setup of test_table_ddl _______________________
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
            raise self._exception
    
        if n == 0:
            return b''
    
        while len(self._buffer) < n:
            if self._eof:
                incomplete = bytes(self._buffer)
                self._buffer.clear()
                raise exceptions.IncompleteReadError(incomplete, n)
    
>           await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
func_name = 'readexactly'
    async def _wait_for_data(self, func_name):
        """Wait until feed_data() or feed_eof() is called.
    
        If stream was paused, automatically resume it.
        """
        # StreamReader uses a future to link the protocol feed_data() method
        # to a read coroutine. Running two read coroutines at the same time
        # would have an unexpected behaviour. It would not possible to know
        # which coroutine would get the next data.
        if self._waiter is not None:
            raise RuntimeError(
                f'{func_name}() called while another coroutine is '
                f'already waiting for incoming data')
    
        assert not self._eof, '_wait_for_data after EOF'
    
        # Waiting for data while paused will make deadlock, so prevent it.
        # This is essential for readexactly(n) for case when n > self._limit.
        if self._paused:
            self._paused = False
            self._transport.resume_reading()
    
        self._waiter = self._loop.create_future()
        try:
>           await self._waiter
/usr/lib/python3.10/asyncio/streams.py:502: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
During handling of the above exception, another exception occurred:
args = ()
kwargs = {'connection': <asyncmy.connection.Connection object at 0xf6573cb8>}
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
setup = <function pytest_fixture_setup.<locals>.wrapper.<locals>.setup at 0xf64e9bb0>
    def wrapper(*args, **kwargs):
        loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs)
    
        async def setup():
            res = await coro(*args, **kwargs)
            return res
    
>       return loop.run_until_complete(setup())
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
    return future.result()
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:140: in setup
    res = await coro(*args, **kwargs)
conftest.py:61: in truncate_table
    await cursor.execute("truncate table test.asyncmy")
asyncmy/cursors.pyx:180: in execute
    ???
asyncmy/cursors.pyx:365: in _query
    ???
asyncmy/connection.pyx:455: in query
    ???
asyncmy/connection.pyx:636: in _read_query_result
    ???
asyncmy/connection.pyx:1023: in read
    ???
asyncmy/connection.pyx:578: in read_packet
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   asyncmy.errors.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')
asyncmy/connection.pyx:612: OperationalError
_________________________ ERROR at setup of test_pool __________________________
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
            raise self._exception
    
        if n == 0:
            return b''
    
        while len(self._buffer) < n:
            if self._eof:
                incomplete = bytes(self._buffer)
                self._buffer.clear()
                raise exceptions.IncompleteReadError(incomplete, n)
    
>           await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
func_name = 'readexactly'
    async def _wait_for_data(self, func_name):
        """Wait until feed_data() or feed_eof() is called.
    
        If stream was paused, automatically resume it.
        """
        # StreamReader uses a future to link the protocol feed_data() method
        # to a read coroutine. Running two read coroutines at the same time
        # would have an unexpected behaviour. It would not possible to know
        # which coroutine would get the next data.
        if self._waiter is not None:
            raise RuntimeError(
                f'{func_name}() called while another coroutine is '
                f'already waiting for incoming data')
    
        assert not self._eof, '_wait_for_data after EOF'
    
        # Waiting for data while paused will make deadlock, so prevent it.
        # This is essential for readexactly(n) for case when n > self._limit.
        if self._paused:
            self._paused = False
            self._transport.resume_reading()
    
        self._waiter = self._loop.create_future()
        try:
>           await self._waiter
/usr/lib/python3.10/asyncio/streams.py:502: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
During handling of the above exception, another exception occurred:
args = ()
kwargs = {'connection': <asyncmy.connection.Connection object at 0xf6573cb8>}
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
setup = <function pytest_fixture_setup.<locals>.wrapper.<locals>.setup at 0xf64e9460>
    def wrapper(*args, **kwargs):
        loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs)
    
        async def setup():
            res = await coro(*args, **kwargs)
            return res
    
>       return loop.run_until_complete(setup())
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
    return future.result()
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:140: in setup
    res = await coro(*args, **kwargs)
conftest.py:61: in truncate_table
    await cursor.execute("truncate table test.asyncmy")
asyncmy/cursors.pyx:180: in execute
    ???
asyncmy/cursors.pyx:365: in _query
    ???
asyncmy/connection.pyx:455: in query
    ???
asyncmy/connection.pyx:636: in _read_query_result
    ???
asyncmy/connection.pyx:1023: in read
    ???
asyncmy/connection.pyx:578: in read_packet
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   asyncmy.errors.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')
asyncmy/connection.pyx:612: OperationalError
______________________ ERROR at setup of test_pool_cursor ______________________
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
            raise self._exception
    
        if n == 0:
            return b''
    
        while len(self._buffer) < n:
            if self._eof:
                incomplete = bytes(self._buffer)
                self._buffer.clear()
                raise exceptions.IncompleteReadError(incomplete, n)
    
>           await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
func_name = 'readexactly'
    async def _wait_for_data(self, func_name):
        """Wait until feed_data() or feed_eof() is called.
    
        If stream was paused, automatically resume it.
        """
        # StreamReader uses a future to link the protocol feed_data() method
        # to a read coroutine. Running two read coroutines at the same time
        # would have an unexpected behaviour. It would not possible to know
        # which coroutine would get the next data.
        if self._waiter is not None:
            raise RuntimeError(
                f'{func_name}() called while another coroutine is '
                f'already waiting for incoming data')
    
        assert not self._eof, '_wait_for_data after EOF'
    
        # Waiting for data while paused will make deadlock, so prevent it.
        # This is essential for readexactly(n) for case when n > self._limit.
        if self._paused:
            self._paused = False
            self._transport.resume_reading()
    
        self._waiter = self._loop.create_future()
        try:
>           await self._waiter
/usr/lib/python3.10/asyncio/streams.py:502: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
During handling of the above exception, another exception occurred:
args = ()
kwargs = {'connection': <asyncmy.connection.Connection object at 0xf6573cb8>}
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
setup = <function pytest_fixture_setup.<locals>.wrapper.<locals>.setup at 0xf7528418>
    def wrapper(*args, **kwargs):
        loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs)
    
        async def setup():
            res = await coro(*args, **kwargs)
            return res
    
>       return loop.run_until_complete(setup())
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
    return future.result()
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:140: in setup
    res = await coro(*args, **kwargs)
conftest.py:61: in truncate_table
    await cursor.execute("truncate table test.asyncmy")
asyncmy/cursors.pyx:180: in execute
    ???
asyncmy/cursors.pyx:365: in _query
    ???
asyncmy/connection.pyx:455: in query
    ???
asyncmy/connection.pyx:636: in _read_query_result
    ???
asyncmy/connection.pyx:1023: in read
    ???
asyncmy/connection.pyx:578: in read_packet
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   asyncmy.errors.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')
asyncmy/connection.pyx:612: OperationalError
------------------------------ Captured log setup ------------------------------
WARNING  asyncio:selector_events.py:911 socket.send() raised exception.
________________________ ERROR at setup of test_acquire ________________________
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
>           raise self._exception
/usr/lib/python3.10/asyncio/streams.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
            raise self._exception
    
        if n == 0:
            return b''
    
        while len(self._buffer) < n:
            if self._eof:
                incomplete = bytes(self._buffer)
                self._buffer.clear()
                raise exceptions.IncompleteReadError(incomplete, n)
    
>           await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
func_name = 'readexactly'
    async def _wait_for_data(self, func_name):
        """Wait until feed_data() or feed_eof() is called.
    
        If stream was paused, automatically resume it.
        """
        # StreamReader uses a future to link the protocol feed_data() method
        # to a read coroutine. Running two read coroutines at the same time
        # would have an unexpected behaviour. It would not possible to know
        # which coroutine would get the next data.
        if self._waiter is not None:
            raise RuntimeError(
                f'{func_name}() called while another coroutine is '
                f'already waiting for incoming data')
    
        assert not self._eof, '_wait_for_data after EOF'
    
        # Waiting for data while paused will make deadlock, so prevent it.
        # This is essential for readexactly(n) for case when n > self._limit.
        if self._paused:
            self._paused = False
            self._transport.resume_reading()
    
        self._waiter = self._loop.create_future()
        try:
>           await self._waiter
/usr/lib/python3.10/asyncio/streams.py:502: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
During handling of the above exception, another exception occurred:
args = ()
kwargs = {'connection': <asyncmy.connection.Connection object at 0xf6573cb8>}
loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
setup = <function pytest_fixture_setup.<locals>.wrapper.<locals>.setup at 0xf650ad60>
    def wrapper(*args, **kwargs):
        loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs)
    
        async def setup():
            res = await coro(*args, **kwargs)
            return res
    
>       return loop.run_until_complete(setup())
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:143: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
    return future.result()
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:140: in setup
    res = await coro(*args, **kwargs)
conftest.py:61: in truncate_table
    await cursor.execute("truncate table test.asyncmy")
asyncmy/cursors.pyx:180: in execute
    ???
asyncmy/cursors.pyx:365: in _query
    ???
asyncmy/connection.pyx:455: in query
    ???
asyncmy/connection.pyx:636: in _read_query_result
    ???
asyncmy/connection.pyx:1023: in read
    ???
asyncmy/connection.pyx:578: in read_packet
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   asyncmy.errors.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')
asyncmy/connection.pyx:612: OperationalError
------------------------------ Captured log setup ------------------------------
WARNING  asyncio:selector_events.py:911 socket.send() raised exception.
______________________ ERROR at teardown of test_acquire _______________________
    def finalizer():
        """Yield again, to finalize."""
        async def async_finalizer():
            try:
                await gen_obj.__anext__()
            except StopAsyncIteration:
                pass
            else:
                msg = "Async generator fixture didn't stop."
                msg += "Yield only once."
                raise ValueError(msg)
>       loop.run_until_complete(async_finalizer())
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.10/asyncio/base_events.py:641: in run_until_complete
    return future.result()
/usr/lib/python3.10/site-packages/pytest_asyncio/plugin.py:117: in async_finalizer
    await gen_obj.__anext__()
conftest.py:36: in connection
    await conn.ensure_closed()
asyncmy/connection.pyx:320: in ensure_closed
    ???
/usr/lib/python3.10/asyncio/streams.py:360: in drain
    raise exc
asyncmy/connection.pyx:610: in asyncmy.connection.Connection._read_bytes
    ???
/usr/lib/python3.10/asyncio/streams.py:697: in readexactly
    raise self._exception
asyncmy/connection.pyx:610: in asyncmy.connection.Connection._read_bytes
    ???
/usr/lib/python3.10/asyncio/streams.py:697: in readexactly
    raise self._exception
asyncmy/connection.pyx:610: in asyncmy.connection.Connection._read_bytes
    ???
/usr/lib/python3.10/asyncio/streams.py:697: in readexactly
    raise self._exception
asyncmy/connection.pyx:610: in asyncmy.connection.Connection._read_bytes
    ???
/usr/lib/python3.10/asyncio/streams.py:697: in readexactly
    raise self._exception
asyncmy/connection.pyx:610: in asyncmy.connection.Connection._read_bytes
    ???
/usr/lib/python3.10/asyncio/streams.py:697: in readexactly
    raise self._exception
asyncmy/connection.pyx:610: in asyncmy.connection.Connection._read_bytes
    ???
/usr/lib/python3.10/asyncio/streams.py:697: in readexactly
    raise self._exception
asyncmy/connection.pyx:610: in asyncmy.connection.Connection._read_bytes
    ???
/usr/lib/python3.10/asyncio/streams.py:708: in readexactly
    await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:502: in _wait_for_data
    await self._waiter
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
------------------------------ Captured log setup ------------------------------
WARNING  asyncio:selector_events.py:911 socket.send() raised exception.
---------------------------- Captured log teardown -----------------------------
WARNING  asyncio:selector_events.py:911 socket.send() raised exception.
=================================== FAILURES ===================================
_________________________________ test_insert __________________________________
>   ???
asyncmy/connection.pyx:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
n = 4
    async def readexactly(self, n):
        """Read exactly `n` bytes.
    
        Raise an IncompleteReadError if EOF is reached before `n` bytes can be
        read. The IncompleteReadError.partial attribute of the exception will
        contain the partial read bytes.
    
        if n is zero, return empty bytes object.
    
        Returned value is not limited with limit, configured at stream
        creation.
    
        If stream was paused, this function will automatically resume it if
        needed.
        """
        if n < 0:
            raise ValueError('readexactly size can not be less than zero')
    
        if self._exception is not None:
            raise self._exception
    
        if n == 0:
            return b''
    
        while len(self._buffer) < n:
            if self._eof:
                incomplete = bytes(self._buffer)
                self._buffer.clear()
                raise exceptions.IncompleteReadError(incomplete, n)
    
>           await self._wait_for_data('readexactly')
/usr/lib/python3.10/asyncio/streams.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <StreamReader exception=ConnectionResetError(104, 'Connection reset by peer') transport=<_SelectorSocketTransport closed fd=14>>
func_name = 'readexactly'
    async def _wait_for_data(self, func_name):
        """Wait until feed_data() or feed_eof() is called.
    
        If stream was paused, automatically resume it.
        """
        # StreamReader uses a future to link the protocol feed_data() method
        # to a read coroutine. Running two read coroutines at the same time
        # would have an unexpected behaviour. It would not possible to know
        # which coroutine would get the next data.
        if self._waiter is not None:
            raise RuntimeError(
                f'{func_name}() called while another coroutine is '
                f'already waiting for incoming data')
    
        assert not self._eof, '_wait_for_data after EOF'
    
        # Waiting for data while paused will make deadlock, so prevent it.
        # This is essential for readexactly(n) for case when n > self._limit.
        if self._paused:
            self._paused = False
            self._transport.resume_reading()
    
        self._waiter = self._loop.create_future()
        try:
>           await self._waiter
/usr/lib/python3.10/asyncio/streams.py:502: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_SelectorSocketTransport closed fd=14>
    def _read_ready__data_received(self):
        if self._conn_lost:
            return
        try:
>           data = self._sock.recv(self.max_size)
E           ConnectionResetError: [Errno 104] Connection reset by peer
/usr/lib/python3.10/asyncio/selector_events.py:856: ConnectionResetError
During handling of the above exception, another exception occurred:
connection = <asyncmy.connection.Connection object at 0xf6573cb8>
    @pytest.mark.asyncio
    async def test_insert(connection):
>       async with connection.cursor(cursor=DictCursor) as cursor:
tests/test_cursor.py:32: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
asyncmy/cursors.pyx:76: in __aexit__
    ???
asyncmy/cursors.pyx:64: in close
    ???
asyncmy/cursors.pyx:118: in nextset
    ???
asyncmy/cursors.pyx:113: in _nextset
    ???
asyncmy/connection.pyx:459: in next_result
    ???
asyncmy/connection.pyx:636: in _read_query_result
    ???
asyncmy/connection.pyx:1023: in read
    ???
asyncmy/connection.pyx:578: in read_packet
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   asyncmy.errors.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')
asyncmy/connection.pyx:612: OperationalError
----------------------------- Captured stderr call -----------------------------
OverflowError: Python int too large to convert to C unsigned long
=============================== warnings summary ===============================
tests/test_autocommit.py::test_autocommit
  /usr/lib/python3.10/asyncio/base_events.py:1881: Warning: Can't create database 'test'; database exists
    handle._run()
tests/test_cursor.py::test_insert
  /usr/lib/python3.10/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored in: 'asyncmy.protocol.MysqlPacket.read_uint64'
  
  Traceback (most recent call last):
    File "/builddir/build/BUILD/asyncmy-0.2.3/tests/test_cursor.py", line 33, in test_insert
      rows = await cursor.execute(
  OverflowError: Python int too large to convert to C unsigned long
  
    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/test_cursor.py::test_insert - asyncmy.errors.OperationalError: (...
ERROR tests/test_cursor.py::test_delete - asyncmy.errors.OperationalError: (2...
ERROR tests/test_cursor.py::test_executemany - asyncmy.errors.OperationalErro...
ERROR tests/test_cursor.py::test_table_ddl - asyncmy.errors.OperationalError:...
ERROR tests/test_pool.py::test_pool - asyncmy.errors.OperationalError: (2013,...
ERROR tests/test_pool.py::test_pool_cursor - asyncmy.errors.OperationalError:...
ERROR tests/test_pool.py::test_acquire - asyncmy.errors.OperationalError: (20...
ERROR tests/test_pool.py::test_acquire - ConnectionResetError: [Errno 104] Co...
======= 1 failed, 6 passed, 2 warnings, 7 errors in 28801.09s (8:00:01) ========

Using an SSL certificate to connect to Mariadb

Thanks for your library.

To connect to my Mariadb I need to use an SSL certificate.
I could not find in the code how I could transfer the SSL certificate. Perhaps I somehow have to provide it via the connection string?
Could you suggest how I can do this? Thanks.

class Connection:
    """
    Representation of a socket with a mysql server.

    The proper way to get an instance of this class is to call
    connect().

    Establish a connection to the MySQL database. Accepts several
    arguments:

    :param host: Host where the database server is located.
    :param user: Username to log in as.
    :param password: Password to use.
    :param database: Database to use, None to not use a particular one.
    :param port: MySQL port to use, default is usually OK. (default: 3306)
    :param unix_socket: Use a unix socket rather than TCP/IP.
    :param read_timeout: The timeout for reading from the connection in seconds (default: None - no timeout)
    :param write_timeout: The timeout for writing to the connection in seconds (default: None - no timeout)
    :param charset: Charset to use.
    :param sql_mode: Default SQL_MODE to use.
    :param read_default_file:
        Specifies  my.cnf file to read these parameters from under the [client] section.
    :param conv:
        Conversion dictionary to use instead of the default one.
        This is used to provide custom marshalling and unmarshalling of types.
        See converters.
    :param use_unicode:
        Whether or not to default to unicode strings.
        This option defaults to true.
    :param client_flag: Custom flags to send to MySQL. Find potential values in constants.
    :param cursor_cls: Custom cursor class to use.
    :param init_command: Initial SQL statement to run when connection is established.
    :param connect_timeout: The timeout for connecting to the database in seconds.
        (default: 10, min: 1, max: 31536000)
    :param ssl: Optional SSL Context to force SSL
    :param read_default_group: Group to read from in the configuration file.
    :param autocommit: Autocommit mode. None means use server default. (default: False)
    :param local_infile: Boolean to enable the use of LOAD DATA LOCAL  (default: False)
    :param max_allowed_packet: Max size of packet sent to server in bytes. (default: 16MB)
        Only used to limit size of "LOAD LOCAL INFILE" data packet smaller than default (16KB).
    :param auth_plugin_map: A dict of plugin names to a class that processes that plugin.
        The class will take the Connection object as the argument to the constructor.
        The class needs an authenticate method taking an authentication packet as
        an argument.  For the dialog plugin, a prompt(echo, prompt) method can be used
        (if no authenticate method) for returning a string from the user. (experimental)
    :param server_public_key: SHA256 authentication plugin public key value. (default: None)
    :param binary_prefix: Add _binary prefix on bytes and bytearray. (default: False)
    :param db: **DEPRECATED** Alias for database.

    See Connection <https://www.python.org/dev/peps/pep-0249/#connection-objects>_ in the
    specification.
    """

[Question] Switching from aiomysql to asyncmy

Hello, what exactly means "API compatible with aiomysql." ? Because I'm currently using it and want to switch to asyncmy but don't want to change many parts of my code for just database queries. The "wrong" errors I have in aiomysql are "Task was destroyed, but it is pending!" And "An open stream object is being garbage collected; call โ€œstream.close()โ€ explicitly".

So do I need to change code parts or means "API compatible with aiomysql" that I don't need to change anything, except from the import?

Weird connection error

Hello,

Thanks for this great library.
I experienced an issue using it with sqlalchemy. It apprently tries to connect using the pool. But it then get a connection error...
Do you have any idea based on this traceback from where this could happens ?
My code worked perfectly with a sync driver (pymysql). Once I changed it to asyncmy, this connection error occured.

ERROR:Exception in ASGI application
Traceback (most recent call last):
  File "/project/resources/items/repository/variant.py", line 190, in get_variant_by_details_hg38
    result = await self.session.execute(query)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/ext/asyncio/session.py", line 212, in execute
    return await greenlet_spawn(
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 134, in greenlet_spawn
    result = context.throw(*sys.exc_info())
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1688, in execute
    conn = self._connection_for_bind(bind)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1529, in _connection_for_bind
    return self._transaction._connection_for_bind(
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 747, in _connection_for_bind
    conn = bind.connect()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/future/engine.py", line 406, in connect
    return super(Engine, self).connect()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3197, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3276, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3246, in _wrap_pool_connect
    Connection._handle_dbapi_exception_noconnection(
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2100, in _handle_dbapi_exception_noconnection
    util.raise_(
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3243, in _wrap_pool_connect
    return fn()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 310, in connect
    return _ConnectionFairy._checkout(self)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 868, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 476, in checkout
    rec = pool._do_get()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
    self._dec_overflow()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 256, in _create_connection
    return _ConnectionRecord(self)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 371, in __init__
    self.__connect()
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 666, in __connect
    pool.logger.debug("Error on connect(): %s", e)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 661, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 590, in connect
    return dialect.connect(*cargs, **cparams)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 584, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 275, in connect
    await_only(self.asyncmy.connect(*arg, **kw)),
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 76, in await_only
    return current.driver.switch(awaitable)
  File "/project/venv/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 129, in greenlet_spawn
    value = await result
  File "asyncmy/connection.pyx", line 1299, in _connect
  File "asyncmy/connection.pyx", line 555, in connect
  File "asyncmy/connection.pyx", line 532, in asyncmy.connection.Connection.connect
  File "asyncmy/connection.pyx", line 922, in _get_server_information
  File "asyncmy/connection.pyx", line 605, in read_packet
  File "asyncmy/protocol.pyx", line 190, in asyncmy.protocol.MysqlPacket.raise_for_error
  File "asyncmy/protocol.pyx", line 194, in asyncmy.protocol.MysqlPacket.raise_for_error
  File "asyncmy/errors.pyx", line 128, in asyncmy.errors.raise_mysql_exception
  File "asyncmy/errors.pyx", line 134, in asyncmy.errors.raise_mysql_exception
sqlalchemy.exc.OperationalError: (asyncmy.errors.OperationalError) (1040, 'ny connections')
(Background on this error at: https://sqlalche.me/e/14/e3q8)

The database is up and I manage to connect to it.

Does asyncmy support sqlalchemy ORM

https://docs.sqlalchemy.org/en/14/orm/tutorial.html#creating-a-session

What we do is

  async_engine = create_async_engine(
      "mysql+asyncmy:[url]ssl_ca=[cert]",
      future=True,
      pool_pre_ping=True,
      pool_recycle=1800,
  )
  _async_session = sessionmaker(bind=async_engine,
                                autocommit=False,
                                autoflush=False,
                                class_=AsyncSession,
                                expire_on_commit=False)
  
  @asynccontextmanager
  async def aio_session_scope():
      """ Provide a transactional scope around a series of operations"""
      async with _async_session() as session:
          try:
              yield session
              await session.commit()
          except Exception as e:
              await session.rollback()
              raise e
          finally:
              await session.close() 

    async with aio_session_scope() as session:
          records = (await session.execute(statement.offset(offset).limit(limit))).all()

The error thrown is:

 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/ext/asyncio/session.py\", line 211, in execute\
   return await greenlet_spawn(\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py\", line 134, in greenlet_spawn\
   result = context.throw(*sys.exc_info())\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py\", line 1691, in execute\
   conn = self._connection_for_bind(bind)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py\", line 1532, in _connection_for_bind\
   return self._transaction._connection_for_bind(\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py\", line 747, in _connection_for_bind\
   conn = bind.connect()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/future/engine.py\", line 406, in connect\
   return super(Engine, self).connect()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py\", line 3204, in connect\
   return self._connection_cls(self, close_with_result=close_with_result)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py\", line 96, in __init__\
   else engine.raw_connection()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py\", line 3283, in raw_connection\
   return self._wrap_pool_connect(self.pool.connect, _connection)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py\", line 3250, in _wrap_pool_connect\
   return fn()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py\", line 310, in connect\
   return _ConnectionFairy._checkout(self)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py\", line 868, in _checkout\
   fairy = _ConnectionRecord.checkout(pool)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py\", line 476, in checkout\
   rec = pool._do_get()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py\", line 146, in _do_get\
   self._dec_overflow()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py\", line 70, in __exit__\
   compat.raise_(\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py\", line 207, in raise_\
   raise exception\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/impl.py\", line 143, in _do_get\
   return self._create_connection()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py\", line 256, in _create_connection\
   return _ConnectionRecord(self)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py\", line 371, in __init__\
   self.__connect()\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py\", line 666, in __connect\
   pool.logger.debug(\"Error on connect(): %s\", e)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py\", line 70, in __exit__\
   compat.raise_(\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py\", line 207, in raise_\
   raise exception\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/pool/base.py\", line 661, in __connect\
   self.dbapi_connection = connection = pool._invoke_creator(self)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/create.py\", line 590, in connect\
   return dialect.connect(*cargs, **cparams)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py\", line 597, in connect\
   return self.dbapi.connect(*cargs, **cparams)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/asyncmy.py\", line 275, in connect\
   await_only(self.asyncmy.connect(*arg, **kw)),\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py\", line 76, in await_only\
   return current.driver.switch(awaitable)\
 File \"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/_concurrency_py3k.py\", line 129, in greenlet_spawn\
   value = await result\
 File \"asyncmy/connection.pyx\", line 1299, in _connect\
 File \"asyncmy/connection.pyx\", line 555, in connect\
 File \"asyncmy/connection.pyx\", line 533, in asyncmy.connection.Connection.connect\
 File \"asyncmy/connection.pyx\", line 727, in _request_authentication\
 File \"/usr/local/lib/python3.9/asyncio/streams.py\", line 52, in open_connection\
   transport, _ = await loop.create_connection(\
 File \"uvloop/loop.pyx\", line 2069, in create_connection\
 File \"uvloop/loop.pyx\", line 2064, in uvloop.loop.Loop.create_connection\
 File \"uvloop/sslproto.pyx\", line 517, in uvloop.loop.SSLProtocol._on_handshake_complete\
 File \"uvloop/sslproto.pyx\", line 477, in uvloop.loop.SSLProtocol._start_handshake\
AttributeError: 'dict' object has no attribute 'wrap_bio'"

This error will show if we use ssl.

Fails on 3.10 - invalid argument loop

Python 3.10 has removed the use of the loop argument in async io.

The issue is in line 512 and 522 in connection.pyx where it passes in the loop loop=loop. Running on 3.10 and later can be determined by:

use_loop = True if sys.version_info < (3, 10) else False

and this can be used to decide whether to pass in the loop parameter or not.

Cannot install on Windows

I run 21.2.4 version of PIP and Python 3.9.5 on [MSC v.1928 64 bit (AMD64)] on win32

Collecting asyncmy
  Using cached asyncmy-0.1.8.tar.gz (60 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: asyncmy
  Building wheel for asyncmy (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\szymo\appdata\local\programs\python\python39\python.exe' 'c:\users\szymo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\szymo\AppData\Local\Temp\tmpbylr_imx'
       cwd: C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476
  Complete output (92 lines):
  A setup.py file already exists. Using it.
  C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\asyncmy\charset.pxd
    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\asyncmy\connection.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\asyncmy\converters.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  warning: asyncmy\converters.pyx:284:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
  C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\asyncmy\errors.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\asyncmy\protocol.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  Compiling asyncmy\charset.pyx because it changed.
  Compiling asyncmy\connection.pyx because it changed.
  Compiling asyncmy\converters.pyx because it changed.
  Compiling asyncmy\errors.pyx because it changed.
  Compiling asyncmy\protocol.pyx because it changed.
  [1/5] Cythonizing asyncmy\charset.pyx
  [2/5] Cythonizing asyncmy\connection.pyx
  [3/5] Cythonizing asyncmy\converters.pyx
  [4/5] Cythonizing asyncmy\errors.pyx
  [5/5] Cythonizing asyncmy\protocol.pyx
  c:\users\szymo\appdata\local\programs\python\python39\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'language_level'
    warnings.warn(msg)
  running build
  running build_py
  creating C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build
  creating C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9
  creating C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\auth.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\contexts.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\cursors.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\optionfile.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\pool.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\version.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\__init__.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  creating C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\CLIENT.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\COLUMN.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\COMMAND.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\CR.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\ER.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\FIELD_TYPE.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\FLAG.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\SERVER_STATUS.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  copying asyncmy\constants\__init__.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\constants
  creating C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\binlogstream.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\bitmap.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\column.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\constants.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\errors.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\events.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\gtid.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\packets.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\row_events.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\table.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\replication\__init__.py -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy\replication
  copying asyncmy\charset.c -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\charset.pxd -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\charset.pyx -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\connection.c -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\connection.pyx -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\converters.c -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\converters.pyx -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\errors.c -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\errors.pyx -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\protocol.c -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  copying asyncmy\protocol.pyx -> C:\Users\szymo\AppData\Local\Temp\pip-install-g9zcll5k\asyncmy_7a954c26a27641638dc474022ddc7476\build\lib.win-amd64-3.9\asyncmy
  running build_ext
  building 'asyncmy.charset' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  Traceback (most recent call last):
    File "c:\users\szymo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 349, in <module>
      main()
    File "c:\users\szymo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 331, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "c:\users\szymo\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 248, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\poetry\core\masonry\api.py", line 68, in build_wheel
      return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))
    File "C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 72, in make_in
      wb.build()
    File "C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 103, in build
      self._build(zip_file)
    File "C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 135, in _build
      self._run_build_command(setup)
    File "C:\Users\szymo\AppData\Local\Temp\pip-build-env-i62jrr_a\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 163, in _run_build_command
      subprocess.check_call(
    File "c:\users\szymo\appdata\local\programs\python\python39\lib\subprocess.py", line 373, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['c:/users/szymo/appdata/local/programs/python/python39/python.exe', 'C:\\Users\\szymo\\AppData\\Local\\Temp\\pip-install-g9zcll5k\\asyncmy_7a954c26a27641638dc474022ddc7476\\setup.py', 'build', '-b', 'C:\\Users\\szymo\\AppData\\Local\\Temp\\pip-install-g9zcll5k\\asyncmy_7a954c26a27641638dc474022ddc7476\\build']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for asyncmy
Failed to build asyncmy
ERROR: Could not build wheels for asyncmy which use PEP 517 and cannot be installed directly

Same results with venv and without. I even tried manually downloading .whl but it didn't help.
There was issue about it (#1) but it is closed.

library suddenly not loading on M1 mac

I don't know if this being on macos and M1 is important, but it seems like it might be.

This minimal test fails consistantly:

โฏ virtualenv .venv
created virtual environment CPython3.10.3.final.0-64 in 176ms
  creator CPython3Posix(dest=/Users/logi.ragnarsson/asyncmy-test/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/logi.ragnarsson/Library/Application Support/virtualenv)
    added seed packages: pip==22.3.1, setuptools==65.7.0, wheel==0.38.4
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
โฏ source .venv/bin/activate
โฏ pip install asyncmy==0.2.5
Looking in indexes: https://pypi.org/simple, <redacted>
Collecting asyncmy==0.2.5
  Using cached asyncmy-0.2.5-cp310-cp310-macosx_13_0_arm64.whl
Installing collected packages: asyncmy
Successfully installed asyncmy-0.2.5

[notice] A new release of pip available: 22.3.1 -> 23.0
[notice] To update, run: pip install --upgrade pip
โฏ python3
Python 3.10.3 (main, Mar 27 2022, 13:44:57) [Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncmy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/logi.ragnarsson/asyncmy-test/.venv/lib/python3.10/site-packages/asyncmy/__init__.py", line 1, in <module>
    from .connection import Connection, connect  # noqa:F401
ModuleNotFoundError: No module named 'asyncmy.connection'

If I install cython and then run pyximport.install() it works, but now we're building the library at startup which is much too slow. Also, using 0.2.7rc6 works immediately.

asyncmy major backwards-incompatible change to TIME datatype in the 0.2.4 point release

hey there -

it looks like asyncmy 0.2.4 suddenly changed the return format for TIME datatypes from a datetime.timedelta() , which is for whatever reason universally returned from all MySQL drivers, to now return the fully formed time() object, which is nice, but this is extremely backwards incompatible and belongs in asyncmy 0.3 at the very earliest, and preferably not at all by default as no other MySQL driver does this. See example below; all drivers return a timedelta(). It would be very helpful if this behavior by default could be reverted and perhaps made some kind of option.

test suite for asyncmy:

import asyncmy
import datetime


def time_from_mysql_delta(value):
    # convert from a timedelta value
    if value is not None:
        microseconds = value.microseconds
        seconds = value.seconds
        minutes = seconds // 60
        return datetime.time(
            minutes // 60,
            minutes % 60,
            seconds - minutes * 60,
            microsecond=microseconds,
        )
    else:
        return None

async def main():
    conn = await asyncmy.connect(user="scott", password="tiger", host="localhost", database="test")
    cursor = conn.cursor()

    await cursor.execute("""
create table if not exists time_test (data time)
""")

    data = datetime.time(12, 15, 23)
    await cursor.execute("delete from time_test")
    await cursor.execute("insert into time_test (data) values(%s)", (data, ))

    await cursor.execute("select data from time_test")
    row = await cursor.fetchone()
    assert time_from_mysql_delta(row[0]) == data

import asyncio
asyncio.run(main())

here's mysqlclient, pymysql, mariadbconnector, mysql connector; they all return a timedelta

import datetime



def time_from_mysql_delta(value):
    # convert from a timedelta value
    if value is not None:
        microseconds = value.microseconds
        seconds = value.seconds
        minutes = seconds // 60
        return datetime.time(
            minutes // 60,
            minutes % 60,
            seconds - minutes * 60,
            microsecond=microseconds,
        )
    else:
        return None

def go(driver):
    conn = driver.connect(user="scott", password="tiger", host="localhost", database="test")
    cursor = conn.cursor()

    cursor.execute("""
drop table if exists time_test
""")
    cursor.execute("""
create table time_test (data time)
""")

    data = datetime.time(12, 15, 23)
    cursor.execute("delete from time_test")
    cursor.execute("insert into time_test (data) values(%s)", (data, ))

    print(f"Running driver: {driver}")
    cursor.execute("select data from time_test")
    row = cursor.fetchone()
    print(f"row received: {row}")
    time_from_mysql_delta(row[0]) == data

    conn.close()


import MySQLdb as mysqlclient
import pymysql
import mariadb
from mysql import connector as mysql


for driver in [mysqlclient, mariadb, pymysql, mysql]:
    go(driver)

output:

Running driver: <module 'MySQLdb' from '/home/classic/.venv3/lib/python3.10/site-packages/MySQLdb/__init__.py'>
row received: (datetime.timedelta(seconds=44123),)
Running driver: <module 'mariadb' from '/home/classic/.venv3/lib/python3.10/site-packages/mariadb/__init__.py'>
row received: (datetime.timedelta(seconds=44123),)
Running driver: <module 'pymysql' from '/home/classic/.venv3/lib/python3.10/site-packages/pymysql/__init__.py'>
row received: (datetime.timedelta(seconds=44123),)
Running driver: <module 'mysql.connector' from '/home/classic/.venv3/lib/python3.10/site-packages/mysql/connector/__init__.py'>
row received: (datetime.timedelta(seconds=44123),)

thanks!

How to ping each connection in a pool?

I'm getting connection lost errors even though I'm periodically calling ping. Is there a correct way to ping all connections in the pool to keep them open? If I call this every minute we should loop through all connections in the pool and ping them right?

    async with pool.acquire() as conn:
      await conn.ping(True)

ERROR: Could not build wheels for asyncmy which use PEP 517 and cannot be installed directly

I'm working on platform [MSC v.1900 64 bit (AMD64)] on win32 with python3.7.7 + pip 21.0.1

When I try to install asyncmy :

pip install asyncmy 

I get errors as below:

Collecting asyncmy
  Using cached asyncmy-0.1.3.tar.gz (43 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: asyncmy
  Building wheel for asyncmy (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\virtual\Envs\venv37\Scripts\python.exe' 'D:\virtual\Envs\venv37\lib\s
ite-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\AppData\Local\Temp\tmpy7lkf9p5'
       cwd: C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920
  Complete output (87 lines):
  A setup.py file already exists. Using it.
  Compiling asyncmy\charset.pyx because it changed.
  Compiling asyncmy\connection.pyx because it changed.
  Compiling asyncmy\converters.pyx because it changed.
  Compiling asyncmy\errors.pyx because it changed.
  Compiling asyncmy\protocol.pyx because it changed.
  Compiling asyncmy/constants\__init__.py because it changed.
  [1/6] Cythonizing asyncmy/constants\__init__.py
  [2/6] Cythonizing asyncmy\charset.pyx
  [3/6] Cythonizing asyncmy\connection.pyx
  [4/6] Cythonizing asyncmy\converters.pyx
  [5/6] Cythonizing asyncmy\errors.pyx
  [6/6] Cythonizing asyncmy\protocol.pyx
  running build
  running build_py
  creating C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build
  creating C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build\lib.win-
amd64-3.7
  creating C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build\lib.win-
amd64-3.7\asyncmy
  copying asyncmy\auth.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f
920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\contexts.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91
af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\cursors.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91a
f0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\optionfile.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f
91af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\pool.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f
920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\version.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91a
f0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\__init__.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91
af0f920\build\lib.win-amd64-3.7\asyncmy
  creating C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build\lib.win-
amd64-3.7\asyncmy\constants
  copying asyncmy\constants\__init__.py -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9
dac2b09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\charset.c -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af
0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\charset.pxd -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91
af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\charset.pyx -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91
af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\connection.c -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f9
1af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\connection.pyx -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09
f91af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\converters.c -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f9
1af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\converters.pyx -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09
f91af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\errors.c -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0
f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\errors.pyx -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91a
f0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\protocol.c -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91a
f0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\protocol.pyx -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f9
1af0f920\build\lib.win-amd64-3.7\asyncmy
  copying asyncmy\constants\CLIENT.pxi -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9d
ac2b09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\constants\COMMAND.pxi -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9
dac2b09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\constants\CR.pxi -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b
09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\constants\ER.pxi -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b
09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\constants\FIELD_TYPE.pxi -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c3894
4b9dac2b09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\constants\FLAG.pxi -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac
2b09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\constants\SERVER_STATUS.pxi -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c3
8944b9dac2b09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  copying asyncmy\constants\__init__.c -> C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9d
ac2b09f91af0f920\build\lib.win-amd64-3.7\asyncmy\constants
  running build_ext
  building 'asyncmy.charset' extension
  creating C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build\temp.win
-amd64-3.7
  creating C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build\temp.win
-amd64-3.7\Release
  creating C:\Users\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build\temp.win
-amd64-3.7\Release\asyncmy
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\vi
rtual\Envs\venv37\include -ID:\python37\include -ID:\python37\include "-IC:\Program Files (x86)\Microso
ft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Wi
ndows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcasyncmy\charset.c /FoC:\Users\Dom
ob\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\build\temp.win-amd64-3.7\Release\asyn
cmy\charset.obj
  charset.c
  d:\python37\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
  C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureW
arning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\U
sers\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\asyncmy\constants\__init__.py

    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureW
arning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\U
sers\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\asyncmy\charset.pxd
    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureW
arning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\U
sers\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\asyncmy\connection.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureW
arning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\U
sers\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\asyncmy\converters.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureW
arning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\U
sers\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\asyncmy\errors.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureW
arning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\U
sers\AppData\Local\Temp\pip-install-m3da5atj\asyncmy_f8bb358c38944b9dac2b09f91af0f920\asyncmy\protocol.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit sta
tus 2
  Traceback (most recent call last):
    File "D:\virtual\Envs\venv37\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <mo
dule>
      main()
    File "D:\virtual\Envs\venv37\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in mai
n
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "D:\virtual\Envs\venv37\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 205, in bui
ld_wheel
      metadata_directory)
    File "C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\poetry\core\masonry\api.py",
 line 68, in build_wheel
      return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))
    File "C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\poetry\core\masonry\builders
\wheel.py", line 72, in make_in
      wb.build()
    File "C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\poetry\core\masonry\builders
\wheel.py", line 103, in build
      self._build(zip_file)
    File "C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\poetry\core\masonry\builders
\wheel.py", line 135, in _build
      self._run_build_command(setup)
    File "C:\Users\AppData\Local\Temp\pip-build-env-c7oj0ttl\overlay\Lib\site-packages\poetry\core\masonry\builders
\wheel.py", line 169, in _run_build_command
      str(self._path / "build"),
    File "D:\python37\lib\subprocess.py", line 363, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['D:/virtual/Envs/venv37/Scripts/python.exe', 'C:\\Users\\Dom
ob\\AppData\\Local\\Temp\\pip-install-m3da5atj\\asyncmy_f8bb358c38944b9dac2b09f91af0f920\\setup.py', 'build', '-b', 'C:\\
Users\\AppData\\Local\\Temp\\pip-install-m3da5atj\\asyncmy_f8bb358c38944b9dac2b09f91af0f920\\build']' returned non
-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for asyncmy
Failed to build asyncmy
ERROR: Could not build wheels for asyncmy which use PEP 517 and cannot be installed directly


Can you help me to get asyncmy installed correctly?

Lost connection to MySQL server despite periodic pings

Every 60 seconds I acquire from my pool and ping yet I'm still getting lost connections. Is ping working or is this not the way to prevent this problem? Am I not walking through all connections in the pool?

(2013, 'Lost connection to MySQL server during query')

    await asyncio.sleep(60)

    async with ws.pool.mysql_pool.acquire() as conn:
      await conn.ping(True)

Aborted connections

I am getting the following error:

2022-07-10T08:18:46.290142Z 10 [Note] Aborted connection 10 to db: '...' user: '...' host: '...' (Got an error reading communication packets)

This happens on a simple use case:

import asyncio
import asyncmy


async def main():
    conn = await asyncmy.connect(...)
    async with conn.cursor() as cursor:
        await cursor.execute("SELECT 1")
        ret = await cursor.fetchall()
        print(ret)


asyncio.run(main())

Am I doing something wrong with connection management?

Windows installation error

I've followed up with instruction but I'm still see an error below

ERROR: Command errored out with exit status 1:
command: 'C:\Users\ADCIKB9\ce-svc-studio-query\env\Scripts\python.exe' 'C:\Users\ADCIKB9\ce-svc-studio-query\env\lib\site-packages\pip_vendor\pep517\in_process_in_process.py' build_wheel 'C:\Users\ADCIKB9\AppData\Local
Temp\tmpirmgnked'
cwd: C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f
Complete output (93 lines):
A setup.py file already exists. Using it.
C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later
release! File: C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\asyncmy\charset.pxd
tree = Parsing.p_module(s, pxd, full_module_name)
C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later
release! File: C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\asyncmy\connection.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later
release! File: C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\asyncmy\converters.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
warning: asyncmy\converters.pyx:284:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later
release! File: C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\asyncmy\errors.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later
release! File: C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\asyncmy\protocol.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
Compiling asyncmy\charset.pyx because it changed.
Compiling asyncmy\connection.pyx because it changed.
Compiling asyncmy\converters.pyx because it changed.
Compiling asyncmy\errors.pyx because it changed.
Compiling asyncmy\protocol.pyx because it changed.
[1/5] Cythonizing asyncmy\charset.pyx
[2/5] Cythonizing asyncmy\connection.pyx
[3/5] Cythonizing asyncmy\converters.pyx
[4/5] Cythonizing asyncmy\errors.pyx
[5/5] Cythonizing asyncmy\protocol.pyx
C:\Python39\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'language_level'
warnings.warn(msg)
running build
running build_py
creating C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build
creating C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9
creating C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\auth.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\contexts.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\cursors.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\optionfile.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\pool.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\version.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy_init_.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
creating C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\CLIENT.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\COLUMN.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\COMMAND.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\CR.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\ER.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\FIELD_TYPE.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\FLAG.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants\SERVER_STATUS.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
copying asyncmy\constants_init_.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\constants
creating C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\binlogstream.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\bitmap.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\column.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\constants.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\errors.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\events.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\gtid.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\packets.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\row_events.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\table.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication\utils.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\replication_init_.py -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy\replication
copying asyncmy\charset.c -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\charset.pxd -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\charset.pyx -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\connection.c -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\connection.pyx -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\converters.c -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\converters.pyx -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\errors.c -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\errors.pyx -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\protocol.c -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
copying asyncmy\protocol.pyx -> C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build\lib.win-amd64-3.9\asyncmy
running build_ext
building 'asyncmy.charset' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Traceback (most recent call last):
File "C:\Users\ADCIKB9\ce-svc-studio-query\env\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 349, in
main()
File "C:\Users\ADCIKB9\ce-svc-studio-query\env\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 331, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\ADCIKB9\ce-svc-studio-query\env\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 248, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\poetry\core\masonry\api.py", line 68, in build_wheel
return unicode(WheelBuilder.make_in(poetry, Path(wheel_directory)))
File "C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 72, in make_in
wb.build()
File "C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 103, in build
self._build(zip_file)
File "C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 135, in _build
self._run_build_command(setup)
File "C:\Users\ADCIKB9\AppData\Local\Temp\pip-build-env-2jw0igmv\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 163, in _run_build_command
subprocess.check_call(
File "C:\Python39\lib\subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:/Users/ADCIKB9/ce-svc-studio-query/env/Scripts/python.exe', 'C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\setup.py',
'build', '-b', 'C:\Users\ADCIKB9\AppData\Local\Temp\pip-install-4402u2x5\asyncmy_54167abab12f424ba3058cc2db5ee13f\build']' returned non-zero exit status 1.


ERROR: Failed building wheel for asyncmy
Failed to build asyncmy
ERROR: Could not build wheels for asyncmy which use PEP 517 and cannot be installed directly

pool ๅ›žๆ”ถconnๆ—ถ็š„้”™่ฏฏ

ๅฝ“่ฎพ็ฝฎasyncmy.create_poolๆ–นๆณ•ไธญๅ‚ๆ•ฐ๏ผŒpool_recycle>0ๆ—ถ๏ผŒๅญ˜ๅœจ้”™่ฏฏใ€‚

ๆ–‡ไปถ pool.py ไธญ๏ผŒline 133

elif self._recycle > -1 and self._loop.time() - conn.last_usage > self._recycle:

ๅ…ถไธญ conn.last_usage ๅนถๆœชๅฎšไน‰ใ€‚

Doc/license files installed directly in site-packages

The asyncmy package installs its CHANGELOG.md, LICENSE, and README.md directly into site-packages.

$ python3 -m venv _e
$ . _e/bin/activate
(_e) $ pip install asyncmy
(_e) $ ls -l _e/lib64/python3.10/site-packages/
total 28
drwxrwxr-x. 1 ben ben  1052 Jan 14 16:44 asyncmy
drwxrwxr-x. 1 ben ben    88 Jan 14 16:44 asyncmy-0.2.3.dist-info
-rw-rw-r--. 1 ben ben   851 Jan 14 16:44 CHANGELOG.md
drwxrwxr-x. 1 ben ben    66 Jan 14 16:43 _distutils_hack
-rw-rw-r--. 1 ben ben   152 Jan 14 16:43 distutils-precedence.pth
-rw-rw-r--. 1 ben ben 11357 Jan 14 16:44 LICENSE
drwxrwxr-x. 1 ben ben   114 Jan 14 16:43 pip
drwxrwxr-x. 1 ben ben   154 Jan 14 16:43 pip-21.2.3.dist-info
drwxrwxr-x. 1 ben ben    80 Jan 14 16:43 pkg_resources
-rw-rw-r--. 1 ben ben  4930 Jan 14 16:44 README.md
drwxrwxr-x. 1 ben ben   714 Jan 14 16:43 setuptools
drwxrwxr-x. 1 ben ben   146 Jan 14 16:43 setuptools-57.4.0.dist-info

ไธป้”ฎไธ่ƒฝ็”จ่ดŸๆ•ฐๅ—๏ผŸ

ๆ•ฐๆฎๅบ“๏ผš10.4.12-MariaDB
tortoise-orm 0.17.4
asyncmy 0.1.6

่กจ็š„ไธป้”ฎๅฎšไน‰๏ผšid = fields.IntField(pk=True)

ๆ‰ง่กŒ๏ผšXXX.create(id=-1, xx=x)
ๅ‡บ็Žฐ้”™่ฏฏๆ็คบ๏ผš

OverflowError: Python int too large to convert to C long
Exception ignored in: 'asyncmy.protocol.MysqlPacket.read_uint64'
Traceback (most recent call last):
  File "d:\www\.python\lib\site-packages\asyncmy\cursors.py", line 344, in _query
    await conn.query(q)
OverflowError: Python int too large to convert to C long

ๆฃ€ๆŸฅๆ•ฐๆฎๅบ“๏ผŒๅ‘็Žฐๆ•ฐๆฎๅทฒ็ปๆญฃๅธธๆ’ๅ…ฅๆ•ฐๆฎๅบ“ใ€‚ไฝ†ๅฐฑๆ˜ฏasyncmy่ฆๆŠฅ้”™

`write_timeout` and `read_timeout` connection parameters are unused/unsupported

The write_timeout and read_timeout connection parameters that can be passed to Connection seem to be entirely unused/unimplemented.
This leads to it not being possible to cancel queries on broken connections through SQLAlchemy in a reasonable timeframe before it's pool_recycle closes the connection.
It would be nice for this to be implemented as the library otherwise looks solid. Otherwise I think the parameters should be removed to not mislead users.

AttributeError: 'SSCursor' object has no attribute '_clear_result' as of 0.2.1

the following test case succeeds in 0.2.0, fails in 0.2.1 and 0.2.2:

import asyncio

import asyncmy
import asyncmy.cursors

async def main():

    conn = await asyncmy.connect(user="scott", password="tiger", database="test", host="localhost")

    await conn.autocommit(True)

    cursor = conn.cursor(asyncmy.cursors.SSCursor)

    await cursor.execute("SELECT 1")

    assert await cursor.fetchone() == (1, )

    await cursor.close()

asyncio.run(main())

stack:

Traceback (most recent call last):
  File "/home/classic/dev/sqlalchemy/test4.py", line 20, in <module>
    asyncio.run(main())
  File "/usr/lib64/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/classic/dev/sqlalchemy/test4.py", line 14, in main
    await cursor.execute("SELECT 1")
  File "asyncmy/cursors.pyx", line 180, in execute
  File "asyncmy/cursors.pyx", line 472, in _query
AttributeError: 'SSCursor' object has no attribute '_clear_result'

Add wheel for aarch64

I see that on PyPI there is only amd64 available for Linux. Is it possible to add Arm 64?

should Cursor.fetchone() be async?

in the example provided on the README the code res = await cursor.fetchone() cannot work, since fetchone() is not defined as async, and the same goes for fetchmany. On the other hand, fetchone and fetchmany are declared as async in the SSCursor implementation. I noticed it because i tried to use asyncmy as an aiomysql drop-in replacement, and using fetchone triggered the exception TypeError: object tuple can't be used in 'await' expression. I suppose those two methods should be declared as async?

0.2.6 release at PyPi: "No source distribution files available for this release."

PyPi misses source distribution files (.tar.gz) which prevents latest 0.2.6 version to be installed on some systems using pip or pipenv.
For example, I use MacOS on ARM platform. There is no generated .whl distributions for the platform and no .tar.gz. So I can not install latest version on local machine.
Previous release (0.2.5) has .tar.gz distrubution, although it cannot be properly installed due to latest issue #48.

ModuleNotFoundError: No module named 'asyncmy.connection'

I use sqlalchemy 1.4.41 and asyncmy 0.2.5 to create async engine in python 3.8 and 3.10, but the program threw
ModuleNotFoundError: No module named 'asyncmy.connection'
when i change asyncmy version to asyncmy 0.2.7rc6, this problem was solved
Are there any bugs in asyncmy 0.2.5? How can i use it and solve this problem

OverflowError: Python int too large to convert to C long

Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
sqlalchemy 1.4.29

one statement is : where(paymentTime <= result) ,the result is 1642664534000.
when I change the statement to where(paymentTime <= result/1000),there is no exception.

thanks.

Traceback (most recent call last):
File "G:\ProgramData\Anaconda3\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 375, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "G:\ProgramData\Anaconda3\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "G:\ProgramData\Anaconda3\lib\site-packages\fastapi\applications.py", line 211, in call
await super().call(scope, receive, send)
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\middleware\errors.py", line 181, in call
raise exc
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\middleware\errors.py", line 159, in call
await self.app(scope, receive, _send)
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\exceptions.py", line 82, in call
raise exc
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\routing.py", line 656, in call
await route.handle(scope, receive, send)
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\routing.py", line 259, in handle
await self.app(scope, receive, send)
File "G:\ProgramData\Anaconda3\lib\site-packages\starlette\routing.py", line 61, in app
response = await func(request)
File "G:\ProgramData\Anaconda3\lib\site-packages\fastapi\routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "G:\ProgramData\Anaconda3\lib\site-packages\fastapi\routing.py", line 159, in run_endpoint_function
return await dependant.call(**values)
File "H:\gitlabproject\pyfreepro\ormtest.\sql_app\main.py", line 44, in getmax1
db_user = await crud.getmax1(db, id=payTradeId)
File "H:\gitlabproject\pyfreepro\ormtest.\sql_app\crud.py", line 88, in getmax1
newresult = await db.execute(newstmt)
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\ext\asyncio\session.py", line 211, in execute
return await greenlet_spawn(
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\util_concurrency_py3k.py", line 134, in greenlet_spawn
result = context.throw(*sys.exc_info())
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\orm\session.py", line 1692, in execute
result = conn._execute_20(statement, params or {}, execution_options)
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1614, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\sql\elements.py", line 325, in _execute_on_connection
return connection._execute_clauseelement(
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1481, in _execute_clauseelement
ret = self._execute_context(
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1845, in _execute_context
self.handle_dbapi_exception(
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 2030, in handle_dbapi_exception
util.raise
(exc_info[1], with_traceback=exc_info[2])
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\util\compat.py", line 207, in raise

raise exception
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1802, in execute_context
self.dialect.do_execute(
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py", line 732, in do_execute
cursor.execute(statement, parameters)
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\dialects\mysql\asyncmy.py", line 92, in execute
return self.await
(self._execute_async(operation, parameters))
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\util_concurrency_py3k.py", line 76, in await_only
return current.driver.switch(awaitable)
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\util_concurrency_py3k.py", line 129, in greenlet_spawn
value = await result
File "G:\ProgramData\Anaconda3\lib\site-packages\sqlalchemy\dialects\mysql\asyncmy.py", line 104, in _execute_async
result = await self._cursor.execute(operation, parameters)
File "asyncmy\cursors.pyx", line 178, in execute
File "asyncmy\cursors.pyx", line 156, in asyncmy.cursors.Cursor.mogrify
File "asyncmy\cursors.pyx", line 129, in genexpr
File "asyncmy\cursors.pyx", line 129, in genexpr
File "asyncmy\connection.pyx", line 426, in asyncmy.connection.Connection.literal
File "asyncmy\connection.pyx", line 419, in asyncmy.connection.Connection.escape
File "asyncmy\converters.pyx", line 10, in asyncmy.converters.escape_item
File "asyncmy\converters.pyx", line 25, in asyncmy.converters.escape_item
File "asyncmy\converters.pyx", line 48, in asyncmy.converters.escape_int
OverflowError: Python int too large to convert to C long

TypeError: object Cursor can't be used in 'await' expression

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Yannic\PycharmProjects\YouTube\venv\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\Yannic\PycharmProjects\gift-bot\cogs\stats_module.py", line 62, in on_message
    mycursor = await mydb.cursor()
TypeError: object Cursor can't be used in 'await' expression

await mydb.cursor() is async in aiomysql. Why not here?

My code:

mydb = await getConnection()
        mycursor = await mydb.cursor()
        await mycursor.execute("SELECT ignore_role_id, bonus_role_id FROM guild_role_settings WHERE guild_id = %s", (message.author.guild.id,))
        in_database = await mycursor.fetchone()

Pool insert and select not fetching latest

Something like below will not work. I tried with autocommit=True, and connection.select_db('db'); doesn't work either. Thanks

pool = await asyncmy.create_pool()

async def run_insert():
    async with pool.acquire() as conn:
        async with conn.cursor() as cursor:
            await cursor.execute("INSERT INTO table VALUES(1)")
            ret = await cursor.fetchone()
            assert ret == (1,)

async def run_select():
    async with pool.acquire() as conn:
        async with conn.cursor() as cursor:
            await cursor.execute("SELECT * FROM table")
            ret = await cursor.fetchone()
            assert ret == (1,)  # Fails, see nothing.

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

Use enum (or any type) as argumenets

I'm trying to build a query like this Table.column == TopicState.TOPIC_STATE_NONE, but I got a ValueError

TypeError: Argument 'value' has incorrect type (expected str, got TopicState)

  File "asyncmy\connection.pyx", line 426, in asyncmy.connection.Connection.literal
  File "asyncmy\connection.pyx", line 419, in asyncmy.connection.Connection.escape
  File "asyncmy\converters.pyx", line 10, in asyncmy.converters.escape_item
  File "asyncmy\converters.pyx", line 25, in asyncmy.converters.escape_item
TypeError: Argument 'value' has incorrect type (expected str, got TopicState)

To avoid this, I need to Table.column == TopicState.TOPIC_STATE_NONE.value to get enum's underlying value.

In aiomysql, I can add a method translate(self, _escape_table) to support any type, is there any way in asyncmy we can do this?

cannot import error

Hello. I installed this using pip on python 3.8.10 and virtualenv, ubuntu 20.04, and it was installed successfully. But when I ran the first example code from the readme, I got this error from the line from asyncmy import connect:
ImportError: cannot import name 'connect' from partially initialized module 'asyncmy' (most likely due to a circular import)
There is no circular import, It's just a single file with the first example code copied. I commented that import line, then it shows this error for the next line from asyncmy.cursors import DictCursor:
ModuleNotFoundError: No module named 'asyncmy.cursors'; 'asyncmy' is not a package.

Cannot import asyncmy using python:3.11 in docker

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.11/site-packages/asyncmy/init.py", line 1, in
from .connection import Connection, connect # noqa:F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'asyncmy.connection'

Can not install by pdm2.0.3 on Windows

When I try to install asyncmy by pdm2, I got the following error report.

PS C:\Users\WDAGUtilityAccount\Desktop\123> pdm add asyncmy -v
Adding packages to default dependencies: asyncmy
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   asyncmy
pdm.termui:   python>=3.10
pdm.termui:   Adding requirement asyncmy
pdm.termui:   Adding requirement python>=3.10
pdm.termui: ======== Starting round 0 ========
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui: Pinning: asyncmy 0.2.5
pdm.termui: ======== Ending round 1 ========
pdm.termui: ======== Starting round 2 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:    python None
pdm.termui:   asyncmy 0.2.5
  Lock successful
Changes are written to pdm.lock.
Changes are written to pyproject.toml.
Synchronizing working set with lock file: 1 to add, 0 to update, 0 to remove

unearth: Downloading <Link https://files.pythonhosted.org/packages/ca/57/68e75455e84ca789cf2aa8def2bee306c96420f7487a6120c7c6d7ac721e/asyncmy-0.2.5-cp310-cp310-win_amd64.whl (from None)> to C:\Users\WDAGUT~1\AppData\Local\Temp\pdm-build-7huqz92s\asyncmy-0.2.5-cp310-cp310-win_amd64.whl
  x Install asyncmy 0.2.5 failed
pdm.termui: Error occurs:
Traceback (most recent call last):
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\synchronizers.py", line 217, in install_candidate
    self.manager.install(can)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\manager.py", line 39, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\installers.py", line 185, in install_wheel
    _install_wheel(
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\installers.py", line 279, in _install_wheel
    install(source, destination, additional_metadata=additional_metadata or {})
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\installer\_core.py", line 96, in install
    for record_elements, stream, is_executable in source.get_contents():
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\installers.py", line 131, in get_contents
    for element in super().get_contents():
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\installer\sources.py", line 158, in get_contents
    assert record is not None, "In {}, {} is not mentioned in RECORD".format(
AssertionError: In C:\Users\WDAGUT~1\AppData\Local\Temp\pdm-build-7huqz92s\asyncmy-0.2.5-cp310-cp310-win_amd64.whl, asyncmy/auth.py is not mentioned in RECORD
Retry failed jobs
  x Install asyncmy 0.2.5 failed
pdm.termui: Error occurs:
Traceback (most recent call last):
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\synchronizers.py", line 217, in install_candidate
    self.manager.install(can)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\manager.py", line 39, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\installers.py", line 185, in install_wheel
    _install_wheel(
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\installers.py", line 279, in _install_wheel
    install(source, destination, additional_metadata=additional_metadata or {})
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\installer\_core.py", line 96, in install
    for record_elements, stream, is_executable in source.get_contents():
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\installers.py", line 131, in get_contents
    for element in super().get_contents():
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\installer\sources.py", line 158, in get_contents
    assert record is not None, "In {}, {} is not mentioned in RECORD".format(
AssertionError: In C:\Users\WDAGUT~1\AppData\Local\Temp\pdm-build-7huqz92s\asyncmy-0.2.5-cp310-cp310-win_amd64.whl, asyncmy/auth.py is not mentioned in RECORD
Traceback (most recent call last):
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\Scripts\pdm.exe\__main__.py", line 7, in <module>
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\core.py", line 254, in main
    return Core().main(args)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\core.py", line 187, in main
    raise cast(Exception, err).with_traceback(traceback)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\core.py", line 182, in main
    f(options.project, options)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\cli\commands\add.py", line 58, in handle
    actions.do_add(
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\cli\actions.py", line 289, in do_add
    do_sync(
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\cli\actions.py", line 219, in do_sync
    handler.synchronize()
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python310\lib\site-packages\pdm\installers\synchronizers.py", line 402, in synchronize
    raise InstallationError("Some package operations are not complete yet")
pdm.exceptions.InstallationError: Some package operations are not complete yet

Test environment:
Windows 11 22622.436 & Python 3.10.5

PS C:\Users\WDAGUtilityAccount\Desktop\123> pdm info
PDM version:
  2.0.3
Python Interpreter:
  C:\Users\WDAGUtilityAccount\Desktop\123\.venv\Scripts\python.exe (3.10)
Project Root:
  C:/Users/WDAGUtilityAccount/Desktop/123
Project Packages:
  None
PS C:\Users\WDAGUtilityAccount\Desktop\123> pdm info --env
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.5",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.22621",
  "python_full_version": "3.10.5",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "win32"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.