Python连接AZURE DW

talk is cheap,直接上代码

import pyodbc
Server = "xxxxxx"
DB = "txxxx"
User = "xxxxx"
Password = "xxxxxx"

conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + Server + ';DATABASE=' + DB + ';;UID=' + User + ';PWD=' + Password)
conn.autocommit = True #设置自动连接

sql='select top 10 * from xxxx.xxxx '
cur = conn.cursor()
cur.execute(sql)
#conn.commit()
row=cur.fetchall()
for i in row:
    print(i)
cur.close()
conn.close()

结果:

Python连接AZURE DW_第1张图片

你可能感兴趣的:(SQL)