mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Merge branch 'main' into python/model-aiomysql
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
33
python/ql/test/library-tests/frameworks/aiopg/test.py
Normal file
33
python/ql/test/library-tests/frameworks/aiopg/test.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import aiopg
|
||||
|
||||
# Only a cursor can execute sql.
|
||||
async def test_cursor():
|
||||
# Create connection directly
|
||||
conn = await aiopg.connect()
|
||||
cur = await conn.cursor()
|
||||
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
|
||||
|
||||
# Create connection via pool
|
||||
async with aiopg.create_pool() as pool:
|
||||
# Create Cursor via Connection
|
||||
async with pool.acquire() as conn:
|
||||
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 = await 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():
|
||||
engine = await create_engine()
|
||||
conn = await engine.acquire()
|
||||
await conn.execute("sql") # $ getSql="sql" constructedSql="sql"
|
||||
Reference in New Issue
Block a user