import pymssql
conn=pymssql.connect(host='192.168.0.110',user='sa',password='pwd',database='test')
'''
如果和本机数据库交互,只需修改链接字符串
conn=pymssql.connect(host='.',database='Michael')
'''
cur=conn.cursor()
cur.execute('select top 5 * from [dbo].[Dim_Area]')
#如果update/delete/insert记得要conn.commit()
#否则数据库事务无法提交
print (cur.fetchall())
cur.close()
conn.close()