1.因为其它的安装包我都已经安装好了,这里只下载pymssql依赖包 pip install pymssql
2.编写连接代码
import os,pymssql
server="#######"
user="######"
password="#########"
conn=pymssql.connect(server,user,password,database="#####")
cursor=conn.cursor()
cursor.execute("""select getdate()""")
row=cursor.fetchone()
while row:
print("sqlserver version:%s"%(row[0]))
print("hello world!")
row=cursor.fetchone()
conn.close()
执行报错:
OperationalError: (18456, ‘DB-Lib error me