Skip to content

TypeError: 'asyncmy.cursors.Cursor' object can't be awaited #145

@coleifer

Description

@coleifer

The project README describes being API-compatible with aiomysql, but I'm seeing an error trying to simply obtain a cursor. This code should run:

import asyncio

import aiomysql
import asyncmy

async def main(driver):
    pool = await driver.create_pool(db='peewee_test', autocommit=True)

    conn = await pool.acquire()
    curs = await conn.cursor()
    res = await curs.execute('select 1')
    print(res)

    pool.release(conn)
    pool.close()

print('aiomysql:')
asyncio.run(main(aiomysql))

print('asyncmy:')
asyncio.run(main(asyncmy))

Output is expected for aiomysql:

aiomysql:                                                                                       
1   

asyncmy throws an error because the cursor is not awaitable:

asyncmy:                                                                                            
Traceback (most recent call last):                                                                  
  File "/home/charles/envs/notebook/x.py", line 21, in <module>                                 
    asyncio.run(main(asyncmy))                                                                      
    ~~~~~~~~~~~^^^^^^^^^^^^^^^                                                                      
  File "/usr/local/lib/python3.14/asyncio/runners.py", line 204, in run                         
    return runner.run(main)                                                                     
           ~~~~~~~~~~^^^^^^                                                                        
  File "/usr/local/lib/python3.14/asyncio/runners.py", line 127, in run                             
    return self._loop.run_until_complete(task)                                                      
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^                                                      
  File "/usr/local/lib/python3.14/asyncio/base_events.py", line 719, in run_until_complete          
    return future.result()                                                                          
           ~~~~~~~~~~~~~^^                                                                          
  File "/home/charles/envs/notebook/x.py", line 10, in main                                         
    curs = await conn.cursor()                                                                      
           ^^^^^^^^^^^^^^^^^^^                    
TypeError: 'asyncmy.cursors.Cursor' object can't be awaited          

Running asyncmy==0.2.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions