Python SQLAlchemy-执行存储过程并填充类
有没有办法执行存储过程并返回类 我试过:Python SQLAlchemy-执行存储过程并填充类,python,sql,stored-procedures,orm,sqlalchemy,Python,Sql,Stored Procedures,Orm,Sqlalchemy,有没有办法执行存储过程并返回类 我试过: session.query(MyClass).from_statement(...) 其中myclass定义为: MyClass(Base): id = Column(Integer) name = Column(String) ... 我知道我应该说: __tablename__ ‘sometable’ 但是没有表,因为所有行都是存储过程调用的结果。你知道有什么办法可以解决这个问题吗?迈克尔·拜耳回购协议的所有者 SQ
session.query(MyClass).from_statement(...)
其中myclass定义为:
MyClass(Base):
id = Column(Integer)
name = Column(String)
...
我知道我应该说:
__tablename__ ‘sometable’
但是没有表,因为所有行都是存储过程调用的结果。你知道有什么办法可以解决这个问题吗?迈克尔·拜耳回购协议的所有者 SQLAlchemy目前不支持除Oracle之外的任何后端上的OUT参数。要立即使用OUT参数,需要使用DBAPI函数callproc(),请参阅 您的函数应该如下所示:
def execproc(procname, engine, queryParams=[]):
connection = engine.raw_connection()
cursor = connection.cursor()
try:
cursor.callproc(procname, queryParams)
rows = list(cursor.fetchall())
cursor.close()
connection.commit()
return rows
finally:
connection.close()