Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中将Azure Bot连接到Azure SQL_Python_Sql_Azure_Bots - Fatal编程技术网

在Python中将Azure Bot连接到Azure SQL

在Python中将Azure Bot连接到Azure SQL,python,sql,azure,bots,Python,Sql,Azure,Bots,我正在用Python中的Azure机器人框架SDK构建一个机器人。 bot需要能够查询同样托管在Azure上的SQL DB 然而,当我试图 async def on_message_activity(self, turn_context: TurnContext): cnxn = pyodbc.connect(<connectionstring>) self.cursor = cnxn.cursor() self.cursor.execute("SELECT

我正在用Python中的Azure机器人框架SDK构建一个机器人。 bot需要能够查询同样托管在Azure上的SQL DB

然而,当我试图

async def on_message_activity(self, turn_context: TurnContext):
    cnxn = pyodbc.connect(<connectionstring>)
    self.cursor = cnxn.cursor()
    self.cursor.execute("SELECT * from tableA")
    desc = self.cursor.description

我已启用Azure服务来访问SQL数据库,并对连接字符串进行了三次检查。我错过什么了吗?这是从bot查询SQL数据库的正确方法吗?

我最终使用Azure函数构建了一个RESTAPI来进行查询。避免来自bot的直接查询,这可能是危险的,总体而言,这是一个更好、更干净的解决方案

There was an error sending this message to your bot: HTTP status code ServiceUnavailable