Created
February 17, 2021 22:50
-
-
Save JeremyMcCormick/719a9b85657299c1875a12af42fb6682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Connect to an MS SQL Server and execute a query | |
""" | |
import pyodbc | |
conn = pyodbc.connect('Driver={SQL Server};' | |
'Server=THINKSGIVING\SQL;' | |
'Database=AdventureWorks2017;' | |
'Trusted_Connection=yes;') | |
cursor = conn.cursor() | |
cursor.execute('SELECT TOP 100 * FROM AdventureWorks2017.Person.Person') | |
for row in cursor: | |
print(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment