调用存储过程后的SQLAlchemy查询

时间:2017-06-12 20:34:36

标签: python mysql session sqlalchemy

我有一个MySQL存储过程来更新表中的某些行。在我调用SP之后我需要咨询throw session.query ....但是会话没有刷新。 我的联系是:

connection = engine.raw_connection()
try:
    cursor = connection.cursor()
    cursor.callproc('nameSP',[1])
    result = list(cursor.fetchall())
    cursor.close()
    connection.commit()
except Exception as e:
    raise InternalServerError(e)
finally:
    connection.close()

对SP的调用:

session.query(Table).filter()

最后,我尝试执行查询session.expire_all()并且结果未更新,但在数据库中没问题,然后我重新启动应用程序并更新信息。 此外,我尝试在执行SP后添加class Task { public: string contents; }; class Task4Answ : public Task { public: string a,b,c,d; Task4Answ(string contents1,string a1,string b1,string c1,string d1) { contents=contents1; a=a1; b=b1; c=c1; d=d1; } }; class TaskNumber : public Task { public: int right; TaskNumber(string contents1, int pop) { contents=contents1; right=pop; } }; class TaskString : public Task { private:; string poprawna; public: ZadanieNumer(string tresc1,string pop) { contents=contents1; poprawna=pop; } }; class TaskCollection { // Here i need to make an array which contains the objects of 3 classes, and method which will put them into array }; ,但它不起作用。

感谢。

0 个答案:

没有答案