{"id":26736,"library":"asyncmy2","title":"asyncmy2","description":"A fast asyncio MySQL driver with native Python coroutines and automatic connection pooling. Version 0.2.20, requires Python >=3.10, actively maintained.","status":"active","version":"0.2.20","language":"python","source_language":"en","source_url":"https://github.com/james-lambert/asyncmy2","tags":["mysql","asyncio","database","driver","async"],"install":[{"cmd":"pip install asyncmy2","lang":"bash","label":"latest"}],"dependencies":[],"imports":[{"note":"asyncmy uses 'asyncmy.connect', but asyncmy2 moved to top-level","symbol":"connect","correct":"from asyncmy2 import connect"},{"note":"Pool is in asyncmy2.pool, not asyncmy.pool","symbol":"Pool","correct":"from asyncmy2.pool import Pool"}],"quickstart":{"code":"import asyncio\nfrom asyncmy2 import connect\n\nasync def main():\n    conn = await connect(host='127.0.0.1', port=3306, user='user', password='pass', db='test')\n    async with conn.cursor() as cur:\n        await cur.execute(\"SELECT 1\")\n        result = await cur.fetchone()\n        print(result)\n    await conn.ensure_closed()\n\nasyncio.run(main())","lang":"python","description":"Connect to MySQL and run a simple query."},"warnings":[{"fix":"Use consistent imports from asyncmy2 only.","message":"asyncmy2 is not a drop-in replacement for asyncmy. The import paths and API differ. Do not mix asyncmy2 with asyncmy in the same project.","severity":"breaking","affected_versions":"all"},{"fix":"Always call `await conn.ensure_closed()` after use, or use context managers if available.","message":"Connections must be explicitly closed with `await conn.ensure_closed()`. Not doing so can leak connections, especially if using connection pools.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure `await pool.close()` is called during cleanup.","message":"The `Pool` class is not re-entrant. You cannot create a pool inside an already running event loop without proper shutdown. Use `await pool.close()` before the loop ends.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: pip install asyncmy2","cause":"Package not installed or installed as 'asyncmy2' under a different name.","error":"ModuleNotFoundError: No module named 'asyncmy2'"},{"fix":"Verify your MySQL user, password, and host. Ensure the user has permissions.","cause":"Incorrect MySQL credentials.","error":"asyncmy2.exceptions.OperationalError: (1045, \"Access denied for user '...'@'...' (using password: YES)\")"},{"fix":"Use asyncio.run() only once. Do not call asyncmy2 functions after the loop has closed. Create connections inside the main async function.","cause":"Trying to use asyncmy2 after the event loop is closed or when using asyncio.run() incorrectly with nested loops.","error":"RuntimeError: Event loop is closed"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}