Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import aiomysql
- loop = asyncio.get_event_loop()
- async def mysql(loop):
- pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
- user='root', password='',
- db='mysql', loop=loop)
- async with pool.acquire() as conn:
- async with conn.cursor() as cur:
- # ALL OF MY DB WORK HERE
- pool.close()
- await pool.wait_closed()
- loop = asyncio.get_event_loop()
- loop.run_until_complete(mysql(loop))
Add Comment
Please, Sign In to add comment