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

Update README.rst to avoid deprecation warnings #995

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
@@ -45,22 +45,19 @@ Properties are unchanged, so ``conn.prop`` is correct as well as
import aiomysql


async def test_example(loop):
pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
user='root', password='',
db='mysql', loop=loop)
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 42;")
print(cur.description)
(r,) = await cur.fetchone()
assert r == 42
pool.close()
await pool.wait_closed()
async def test_example():
async with aiomysql.create_pool(host='127.0.0.1', port=3306,
user='root', password='',
db='mysql') as pool:
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 42;")
print(cur.description)
(r,) = await cur.fetchone()
assert r == 42


loop = asyncio.get_event_loop()
loop.run_until_complete(test_example(loop))
asyncio.run(test_example())


Example of SQLAlchemy optional integration
@@ -83,9 +80,9 @@ for aiopg_ user.:
sa.Column('val', sa.String(255)))


async def go(loop):
async def go():
engine = await create_engine(user='root', db='test_pymysql',
host='127.0.0.1', password='', loop=loop)
host='127.0.0.1', password='')
async with engine.acquire() as conn:
await conn.execute(tbl.insert().values(val='abc'))
await conn.execute(tbl.insert().values(val='xyz'))
@@ -97,8 +94,7 @@ for aiopg_ user.:
await engine.wait_closed()


loop = asyncio.get_event_loop()
loop.run_until_complete(go(loop))
asyncio.run(go())


Requirements