我试图使用sqlalchemy
从python
调用stored procedure
。我的代码如下:
@database_connection_wrapper
def get_adv(connection):
''' get the adv using a stored proc from the database '''
connection.callproc("GetAdvMedianTrailing30Days")
results = list(connection.fetchall())
print(results)
我得到以下错误:
AttributeError: 'pyodbc.Connection' object has no attribute 'callproc'
我遵循了官方文件上的指示,但这并没有造成任何影响。在
我在python 3.5
有没有不同的方法来调用stored procedures
?在
从https://github.com/mkleehammer/pyodbc/wiki/Calling-Stored-Procedures,
pyodbc
不在连接对象上实现.callproc()
方法。必须使用SQL调用(.execute("{CALL GetAdvMedianTrailing30Days}")
)执行sp。在(这不是一个真正的SQLAlchemy问题,因为您正在泄漏抽象以使用
pyodbc
进行DB-API调用)相关问题 更多 >
编程相关推荐