Skip to content

Commit 360e513

Browse files
authored
Merge pull request #995 from graingert/patch-1
Update README.rst to avoid deprecation warnings
2 parents 0d53700 + e8a4653 commit 360e513

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

README.rst

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,19 @@ Properties are unchanged, so ``conn.prop`` is correct as well as
4545
import aiomysql
4646
4747
48-
async def test_example(loop):
49-
pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
50-
user='root', password='',
51-
db='mysql', loop=loop)
52-
async with pool.acquire() as conn:
53-
async with conn.cursor() as cur:
54-
await cur.execute("SELECT 42;")
55-
print(cur.description)
56-
(r,) = await cur.fetchone()
57-
assert r == 42
58-
pool.close()
59-
await pool.wait_closed()
48+
async def test_example():
49+
async with aiomysql.create_pool(host='127.0.0.1', port=3306,
50+
user='root', password='',
51+
db='mysql') as pool:
52+
async with pool.acquire() as conn:
53+
async with conn.cursor() as cur:
54+
await cur.execute("SELECT 42;")
55+
print(cur.description)
56+
(r,) = await cur.fetchone()
57+
assert r == 42
6058
6159
62-
loop = asyncio.get_event_loop()
63-
loop.run_until_complete(test_example(loop))
60+
asyncio.run(test_example())
6461
6562
6663
Example of SQLAlchemy optional integration
@@ -83,9 +80,9 @@ for aiopg_ user.:
8380
sa.Column('val', sa.String(255)))
8481
8582
86-
async def go(loop):
83+
async def go():
8784
engine = await create_engine(user='root', db='test_pymysql',
88-
host='127.0.0.1', password='', loop=loop)
85+
host='127.0.0.1', password='')
8986
async with engine.acquire() as conn:
9087
await conn.execute(tbl.insert().values(val='abc'))
9188
await conn.execute(tbl.insert().values(val='xyz'))
@@ -97,8 +94,7 @@ for aiopg_ user.:
9794
await engine.wait_closed()
9895
9996
100-
loop = asyncio.get_event_loop()
101-
loop.run_until_complete(go(loop))
97+
asyncio.run(go())
10298
10399
104100
Requirements

0 commit comments

Comments
 (0)