📜  使用 python 连接到 ssms - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:36.388000             🧑  作者: Mango

代码示例1
import pyodbc 
conn = pyodbc.connect('Driver={SQL Server};'
                      'Server=server_name;'
                      'Database=database_name;'
                      'Trusted_Connection=yes;')

cursor = conn.cursor()
cursor.execute('SELECT * FROM database_name.table')

for row in cursor:
    print(row)