Python: model aiomysql

This commit is contained in:
Rasmus Lerchedahl Petersen
2021-11-10 14:29:39 +01:00
parent 047cff0749
commit 57e7bfbdba
5 changed files with 154 additions and 5 deletions

View File

@@ -5,24 +5,24 @@ async def test_cursor():
# Create connection directly
conn = await aiomysql.connect()
cur = await conn.cursor()
await cur.execute("sql") # $ MISSING: getSql="sql" constructedSql="sql"
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
# Create connection via pool
async with aiomysql.create_pool() as pool:
# Create Cursor via Connection
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("sql") # $ MISSING: getSql="sql" constructedSql="sql"
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
# Create Cursor directly
async with pool.cursor() as cur:
await cur.execute("sql") # $ MISSING: getSql="sql" constructedSql="sql"
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
# variants using as few `async with` as possible
pool = await aiomysql.create_pool()
conn = await pool.acquire()
cur = await conn.cursor()
await cur.execute("sql") # $ MISSING: getSql="sql" constructedSql="sql"
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
# Test SQLAlchemy integration
from aiomysql.sa import create_engine
@@ -30,4 +30,4 @@ from aiomysql.sa import create_engine
async def test_engine():
engine = await create_engine()
conn = await engine.acquire()
await conn.execute("sql") # $ MISSING: getSql="sql" constructedSql="sql"
await conn.execute("sql") # $ getSql="sql" constructedSql="sql"