Skip to content

Commit

Permalink
Merge pull request #437 from Pradhvan/issue_436
Browse files Browse the repository at this point in the history
docs/index.rst: Updated tutorial to native coroutines
  • Loading branch information
asvetlov authored Sep 11, 2019
2 parents b2f8a6d + bec31e3 commit b16e5bd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ of :term:`PyMySQL` . **aiomysql** tries to be like awesome aiopg_ library and pr
same api, look and feel.

Internally **aiomysql** is copy of PyMySQL, underlying io calls switched
to async, basically ``yield from`` and ``asyncio.coroutine`` added in
to async, basically ``await`` and ``async def coroutine`` added in
proper places. :term:`sqlalchemy` support ported from aiopg_.


Expand All @@ -36,7 +36,7 @@ Basics
------

**aiomysql** based on :term:`PyMySQL` , and provides same api, you just need
to use ``yield from conn.f()`` instead of just call ``conn.f()`` for
to use ``await conn.f()`` instead of just call ``conn.f()`` for
every method.

Properties are unchanged, so ``conn.prop`` is correct as well as
Expand All @@ -51,18 +51,18 @@ See example:
loop = asyncio.get_event_loop()
@asyncio.coroutine
def test_example():
conn = yield from aiomysql.connect(host='127.0.0.1', port=3306,
async def test_example():
conn = await aiomysql.connect(host='127.0.0.1', port=3306,
user='root', password='', db='mysql',
loop=loop)
cur = yield from conn.cursor()
yield from cur.execute("SELECT Host,User FROM user")
cur = await conn.cursor()
await cur.execute("SELECT Host,User FROM user")
print(cur.description)
r = yield from cur.fetchall()
r = await cur.fetchall()
print(r)
yield from cur.close()
await cur.close()
conn.close()
loop.run_until_complete(test_example())
Expand Down

0 comments on commit b16e5bd

Please sign in to comment.