Guest User

Untitled

a guest
Aug 30th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import asyncio
  2. import aiomysql
  3.  
  4. loop = asyncio.get_event_loop()
  5.  
  6. async def mysql(loop):
  7. pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
  8. user='root', password='',
  9. db='mysql', loop=loop)
  10. async with pool.acquire() as conn:
  11. async with conn.cursor() as cur:
  12.  
  13. # ALL OF MY DB WORK HERE
  14.  
  15. pool.close()
  16. await pool.wait_closed()
  17.  
  18.  
  19. loop = asyncio.get_event_loop()
  20. loop.run_until_complete(mysql(loop))
Add Comment
Please, Sign In to add comment