Python sqlalchemy 调用存储过程
Python sqlalchemy calling stored procedure
我正在尝试使用 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
(这不是真正的 SQL 炼金术问题,因为您正在泄漏抽象以使用 pyodbc
进行 DB-API 调用)
我正在尝试使用 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}")
).
(这不是真正的 SQL 炼金术问题,因为您正在泄漏抽象以使用 pyodbc
进行 DB-API 调用)