得到错误,同时使用python
问题描述:
我试图通过Python来连接SQL Server和得到以下错误得到错误,同时使用python
SyntaxError: multiple statements found while compiling a single statement
这里连接的SQL Server是我的代码
import pyodbc
>>> cnxn=pyodbc.connect("Drive={SQL serve}"; server=""; database=""; uid="sa"; pwd="")
好心帮我
答
该函数只需要一个参数。所以,你需要提供连接字符串是这样的:
cnxn = pyodbc.connect('DRIVER={MySQL};SOCKET=/var/lib/mysql/mysql.sock;UID=rooter;PWD=sshh')
更多的例子见https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Windows。
您使用分号而不是逗号,用逗号替换所有分号。 'cnxn = pyodbc.connect(“Drive = {SQL serve}”,server =“”,database =“”,uid =“sa”,pwd =“”)' –
用分号替换分号,即使iam得到同样的错误sir 。 –