【发布时间】:2021-09-11 05:20:13
【问题描述】:
无法在 aws lamdba 中执行 pyodbc
AWS Lamba 上的错误。
这是python代码。
import requests
import pyodbc as po
server = '*****'
database = '*****'
username = '*****'
password = '******'
def lambda_handler(event, context):
cnxn = po.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=' +
server + ';DATABASE=' + database + ';UID=' + username + ';PWD=' + password)
cursor = cnxn.cursor()
# Prepare the stored procedure execution script
storedProc = "exec usp_getproducts"
# Execute Stored Procedure With Parameters
cursor.execute(storedProc)
# Iterate the cursor
print(cursor.fetchone())
print(1)
# Close the cursor and delete it
cursor.close()
del cursor
# Close the database connection
cnxn.close()
这是pyodbc的包文件。
我已经制作了上述文件的 zip 并在 Lambda 函数中上传。
请帮忙看看在 AWS lambda 函数中部署 python 代码的更好方法是什么。
【问题讨论】:
标签: python amazon-web-services aws-lambda