I'm trying to execute raw sql and pass it parameters. I'm attempting to follow the instructions set out here as a base: https://github.com/fantix/gino/issues/321
But I can't get anything to work.
I've tried
async with db.acquire() as conn:
promo_audit = await conn.raw_connection.execute('select * from promotion_audit where id = :idName').execution_options(idName=1)
print(promo_audit)
but get back
AttributeError: 'CoroWrapper' object has no attribute 'execution_options'
I tried:
promo_audit = await db.status('select * from promotion_audit where id = ?', 1)
promo_audit = await db.status('select * from promotion_audit where id = :idName', idName=1)
promo_audit = await db.status('select * from promotion_audit where id = :idName', { 'idName' : 1})
promo_audit = await db.status('select * from promotion_audit where id = :idName').execution_options(idName=1)
But get back variations of:
syntax error at or near ":" at character 42
STATEMENT: select * from promotion_audit where id = :idName
Could someone please provide an example of how to do it? Thanks
For now, you need the db.text wrapper:
promo_audit = await db.status(db.text('select * from promotion_audit where id = :idName'), {'idName' : 1})
Thank you so much @fantix ! That works :)
Anytime 馃槂
Most helpful comment
For now, you need the
db.textwrapper: