简体   繁体   中英

How to call the stored procedure with parameters in python?

I have a stored procedure defined escalate which taking a string parameter clientid .

I'm using sqlalchemy in python and using ORM. I have db.session created.

I'm not sure how i could call stored procedure with this session.

Anyone could point me the solution?

I have tried following; but getting an error:

TypeError: get_bind() got an unexpected keyword argument 'param'

Code:

from sqlalchemy import and_, func,text

db.session.execute(text("CALL escalate(:param)"), param=clientid)

From the docs session.execute needs a dict over kwargs, unlike the connection object which should have worked as you wrote it.

db.session.execute(
    "CALL escalate(:param)",
    {'param': clientid}
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM