Skip to content

Commit b16e5bd

Browse files
authored
Merge pull request #437 from Pradhvan/issue_436
docs/index.rst: Updated tutorial to native coroutines
2 parents b2f8a6d + bec31e3 commit b16e5bd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/index.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ of :term:`PyMySQL` . **aiomysql** tries to be like awesome aiopg_ library and pr
1919
same api, look and feel.
2020

2121
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
2323
proper places. :term:`sqlalchemy` support ported from aiopg_.
2424

2525

@@ -36,7 +36,7 @@ Basics
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
4040
every method.
4141

4242
Properties 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

Comments
 (0)