Python连接SQL时找不到提供程序错误

2024-04-19 02:58:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在Python脚本中连接到sqlserver数据库。我使用SQLNCLI作为连接字符串的提供者。在

from win32com.client import Dispatch

connection_string = "Provider=SQLNCLI;server=%s;initial catalog=%s;user id=%s;password=%s"%(server,db_name,user,pwd)

dbConn = Dispatch("ADODB.Connection")

dbConn.Open( connection_string )

执行脚本时出现以下错误:

provider cannot be found. It may not be properly installed.

有什么办法解决这个问题吗?在


Tags: 字符串from脚本数据库stringserver提供者be