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