Skip to content

Instantly share code, notes, and snippets.

@brydavis
Created May 14, 2019 00:50
Show Gist options
  • Save brydavis/503d214cf9350263c72d51520f45068e to your computer and use it in GitHub Desktop.
Save brydavis/503d214cf9350263c72d51520f45068e to your computer and use it in GitHub Desktop.
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