Python访问SQL DB [英] Python access to SQL DB

查看:86
本文介绍了Python访问SQL DB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个读取SQL DB的Azure函数。

I am writing an Azure function that reads SQL DB.

为此我使用pyodbc包

For this I am using pyodbc package

然后做

import pyodbc as podb
conn = podbc.connect(connectString)

其中connectString取自SQL DB的Web门户并填充相关密码。

where connectString is taken from Web portal for SQL DB and filled with relevant password.

给出一些错误,因为使用HttpTrigger的网页渲染失败 

gives some error as the web rendering using HttpTrigger fails 


网站可能正在维护或可能出现编程错误。

The site may be under maintenance or could have a programming error.


-

--


但是代码在本地工作。

However the code works locally.


如果上面的代码被注释掉,Azure函数就可以了。

Azure function works ok if the above code is commented out.


如何在Azure上连接到Python上的SQL DB函数?

How to connect to SQL DB in Python on Azure function?

推荐答案

我了解到,由于代码在os-type Linux上运行,pyodbc可能无法在该环境上安装,从而导致失败。我想知道是否有修复它,或者我必须等到在Windows上启动的功能可用。
I learned that since the code run on os-type Linux, pyodbc can have trouble installing on that env. and hence the failure. I was wondering if there is a fix for it or I have to wait until the functionality to launch on Windows becomes available.


这篇关于Python访问SQL DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆