Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/index.rst: Updated tutorial to native coroutines #437

Merged
merged 1 commit into from
Sep 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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