使用python连接到SQL Server 2008

使用python连接到SQL Server 2008,python,sql-server,pymssql,Python,Sql Server,Pymssql,我正在尝试从python访问MS SQL server 我安装了pymssql,这是我的代码 import pymssql conn = pymssql.connect(host='SAM-WOLPTP\SAM', user='SAM', password='password', database='test') cur = conn.cursor() cur.execute('CREATE TABLE persons(id INT, name VARCHAR(100))') cur.exe

我正在尝试从python访问MS SQL server

我安装了pymssql,这是我的代码

import pymssql

conn = pymssql.connect(host='SAM-WOLPTP\SAM', user='SAM', password='password', database='test')

cur = conn.cursor()
cur.execute('CREATE TABLE persons(id INT, name VARCHAR(100))')
cur.executemany("INSERT INTO persons VALUES(%d, %s)", \
[ (1, 'John Doe'), (2, 'Jane Doe') ])
conn.commit()  # you must call commit() to persist your data if you don't set autocommit to True

conn.close()
运行程序时,我遇到以下错误:

pymssql.InterfaceError:连接到数据库失败,原因未知


看看这个。谢谢我试过了。。我认为这是一个版本问题。我的SQL server是64位的,但pymssql的64位未安装,我尝试使用32位安装。