1
我想从python
使用sqlalchemy
调用stored procedure
。我的代码如下:Python sqlalchemy调用存储过程
@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
?
谢谢! pyodbc.ProgrammingError('42000',“[42000] [Microsoft] [用于SQL Server的ODBC驱动程序13] [SQL Server]的错误在对象'GetAdvMedianTrailing30Days',数据库'XXX'上拒绝EXECUTE权限, ,schema'dbo'(229)(SQLExecDirectW)“)'。我该如何解决这个问题? – PYA
请问您使用SQLAlchemy的用户登录到服务器具有在数据库中执行'GetAdvMedianTrailing30Days'必要的权限? – cowbert
必须问我的团队:P。你发布的github链接真的很有用,因为我存储的proc返回值,我将不得不将它转换成我认为的SQL语句。再次感谢! – PYA