async with GetDBConnectionContext() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT * FROM user WHERE username=%s", (username,))
bug发生
Expected behavior
返回的连接对象中的游标对象成功执行sql语句并返回结果
Logs/tracebacks
[2024-05-11 14:11:30.069| ERROR |MainThread|mysql.login_user|UserControllers.py:57]: 登录用户时发生错
误: 'NoneType' object has no attribute 'send'
Traceback (most recent call last):
File "f:\python_play\furina-fastapi-backend\backend\utils\UserControllers.py", line 34, in login_user
await cur.execute("SELECT * FROM user WHERE username=%s", (username,))
File "G:\python3.12.3\Lib\site-packages\aiomysql\cursors.py", line 239, in execute
await self._query(query)
File "G:\python3.12.3\Lib\site-packages\aiomysql\cursors.py", line 457, in _query
await conn.query(q)
File "G:\python3.12.3\Lib\site-packages\aiomysql\connection.py", line 468, in query
await self._execute_command(COMMAND.COM_QUERY, sql)
File "G:\python3.12.3\Lib\site-packages\aiomysql\connection.py", line 724, in _execute_command
self._write_bytes(prelude + sql[:chunk_size - 1])
File "G:\python3.12.3\Lib\site-packages\aiomysql\connection.py", line 669, in _write_bytes
return self._writer.write(data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\python3.12.3\Lib\asyncio\streams.py", line 346, in write
self._transport.write(data)
File "G:\python3.12.3\Lib\asyncio\proactor_events.py", line 366, in write
self._loop_writing(data=bytes(data))
File "G:\python3.12.3\Lib\asyncio\proactor_events.py", line 402, in _loop_writing
self._write_fut = self._loop._proactor.send(self._sock, data)
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send'
Python Version
$ python --version
3.12.3
aiomysql Version
$ python -m pip show aiomysql
Name: aiomysql
Version: 0.2.0
Summary: MySQL driver for asyncio.
Home-page: https://github.com/aio-libs/aiomysql
Author: Nikolay Novik
Author-email: nickolainovik@gmail.com
License: MIT
Location: G:\python3.12.3\Lib\site-packages
Requires: PyMySQL
Required-by:
PyMySQL Version
$ python -m pip show PyMySQL
Name: PyMySQL
Version: 1.1.0
Summary: Pure Python MySQL Driver
Home-page:
Author:
Author-email: Inada Naoki <songofacandy@gmail.com>, Yutaka Matsubara <yutaka.matsubara@gmail.com>
License: MIT License
Location: G:\python3.12.3\Lib\site-packages
Requires:
Required-by: aiomysql
SQLAlchemy Version
$ python -m pip show sqlalchemy
OS
windows
Database type and version
SELECT VERSION();
8.4.0
Additional context
No response
Code of Conduct
[X] I agree to follow the aio-libs Code of Conduct
Describe the bug
返回的连接对象的游标对象执行sql语句的时候发生了bug
To Reproduce
async with GetDBConnectionContext() as conn: async with conn.cursor() as cur: await cur.execute("SELECT * FROM user WHERE username=%s", (username,)) bug发生
Expected behavior
返回的连接对象中的游标对象成功执行sql语句并返回结果
Logs/tracebacks
Python Version
aiomysql Version
PyMySQL Version
SQLAlchemy Version
OS
windows
Database type and version
Additional context
No response
Code of Conduct