View difference between Paste ID: nJr4Pdge and xWVeWZWx
SHOW: | | - or go back to the newest paste.
1
import pyodbc
2
connStr = (
3
    r"DRIVER={SQL Server Native Client 11.0};"
4
    r"SERVER=(local)\SQLSERVERINSAF;"
5-
    r"Integrated Security=true;")
5+
    r"Trusted_connection=yes;")
6
cnxn = pyodbc.connect(connStr, autocommit=True)
7
8
crsr = cnxn.execute("SELECT name FROM master.dbo.sysdatabases")
9
for row in crsr.fetchall():
10
    print(row[0])
11
12
crsr.close()
13
cnxn.close()