@@ -19,7 +19,7 @@ of :term:`PyMySQL` . **aiomysql** tries to be like awesome aiopg_ library and pr
1919same api, look and feel.
2020
2121Internally **aiomysql ** is copy of PyMySQL, underlying io calls switched
22- to async, basically ``yield from `` and ``asyncio. coroutine `` added in
22+ to async, basically ``await `` and ``async def coroutine `` added in
2323proper places. :term: `sqlalchemy ` support ported from aiopg _.
2424
2525
3636------
3737
3838**aiomysql ** based on :term: `PyMySQL ` , and provides same api, you just need
39- to use ``yield from conn.f() `` instead of just call ``conn.f() `` for
39+ to use ``await conn.f() `` instead of just call ``conn.f() `` for
4040every method.
4141
4242Properties are unchanged, so ``conn.prop `` is correct as well as
@@ -51,18 +51,18 @@ See example:
5151
5252 loop = asyncio.get_event_loop()
5353
54- @asyncio.coroutine
55- def test_example ():
56- conn = yield from aiomysql.connect(host = ' 127.0.0.1' , port = 3306 ,
54+
55+ async def test_example ():
56+ conn = await aiomysql.connect(host = ' 127.0.0.1' , port = 3306 ,
5757 user = ' root' , password = ' ' , db = ' mysql' ,
5858 loop = loop)
5959
60- cur = yield from conn.cursor()
61- yield from cur.execute(" SELECT Host,User FROM user" )
60+ cur = await conn.cursor()
61+ await cur.execute(" SELECT Host,User FROM user" )
6262 print (cur.description)
63- r = yield from cur.fetchall()
63+ r = await cur.fetchall()
6464 print (r)
65- yield from cur.close()
65+ await cur.close()
6666 conn.close()
6767
6868 loop.run_until_complete(test_example())
0 commit comments