Apply suggestions from code review

Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
This commit is contained in:
yoff
2021-11-10 10:51:40 +01:00
committed by GitHub
parent aa1541a5c3
commit a856395d56

View File

@@ -11,13 +11,20 @@ async def test_cursor():
async with aiopg.create_pool() as pool:
# Create Cursor via Connection
async with pool.acquire() as conn:
cur = await conn.cursor()
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
async with conn.cursor() as cur:
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
# Create Cursor directly
async with pool.cursor() as cur:
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
# variants using as few `async with` as possible
pool = await aiopg.create_pool()
conn = pool.acquire()
cur = await conn.cursor()
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
# Test SQLAlchemy integration
from aiopg.sa import create_engine
async def test_engine():