Skip to content Skip to sidebar Skip to footer

Why The Stored Procedure Called From Sqlalchemy Is Not Working But Calling From Workbench Is Working?

I have a stored procedure. calling it via MySQL workbench as follows working; CALL `lobdcapi`.`escalatelobalarm`('A0001'); But not from the python program. (means it is not throwi

Solution 1:

I haven't called stored procs from SQLAlchemy, but it seems possible that this could be within a transaction because you're using the session. Perhaps calling db.session.commit() at the end would help?

If that fails, SQLAlchemy calls out calling stored procs here. Perhaps try their method of using callproc. Adapting to your use-case, something like:

connection = db.session.connection()
try:
    cursor = connection.cursor()
    cursor.callproc("escalatelobalarm", [clientid])
    results = list(cursor.fetchall())
    cursor.close()
    connection.commit()
finally:
    connection.close()

Post a Comment for "Why The Stored Procedure Called From Sqlalchemy Is Not Working But Calling From Workbench Is Working?"