Created
May 14, 2019 00:50
-
-
Save brydavis/503d214cf9350263c72d51520f45068e to your computer and use it in GitHub Desktop.
This file contains 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
import pyodbc | |
connstr = "dsn=someDB;SERVER=LLJIUR2343;DATABASE=someDB;Trusted_Connection=Yes" | |
query = """ | |
select top 1000 * | |
from people | |
""" | |
# connect to the database | |
with pyodbc.connect(connstr) as conn: | |
# execute the query | |
cursor = conn.execute(query) | |
# get results from the query | |
for row in cursor.fetchall(): | |
print(list(row)) | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment