@@ -19,7 +19,7 @@ of :term:`PyMySQL` . **aiomysql** tries to be like awesome aiopg_ library and pr
19
19
same api, look and feel.
20
20
21
21
Internally **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
23
23
proper places. :term: `sqlalchemy ` support ported from aiopg _.
24
24
25
25
36
36
------
37
37
38
38
**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
40
40
every method.
41
41
42
42
Properties are unchanged, so ``conn.prop `` is correct as well as
@@ -51,18 +51,18 @@ See example:
51
51
52
52
loop = asyncio.get_event_loop()
53
53
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 ,
57
57
user = ' root' , password = ' ' , db = ' mysql' ,
58
58
loop = loop)
59
59
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" )
62
62
print (cur.description)
63
- r = yield from cur.fetchall()
63
+ r = await cur.fetchall()
64
64
print (r)
65
- yield from cur.close()
65
+ await cur.close()
66
66
conn.close()
67
67
68
68
loop.run_until_complete(test_example())
0 commit comments