Created
May 19, 2016 16:15
-
-
Save gdevanla/65a02b51427f9f885c934c23a3cfc43a 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
import pyodbc | |
# This will be the query to run | |
sql = 'SELECT * FROM AAF_IS_USER' | |
# conn_str = Here repace USER with treussard and YOUR_PASSWORD with the actual password | |
conn_str = "DRIVER={FreeTDS};DSN=irv_sql02;UID=ra\treussard;PWD=YOUR_PASSWORD;DATABASE=AAF;" | |
# connecting to the database | |
conn = pyodbc.connect(conn_str) | |
# Run the query. This will fetch a cursor | |
c = conn.execute(sql) | |
# Loop through all the records and print the records | |
for r in c.fetchall(): | |
# print comma separated list of fields from each row | |
print(",".join([str(i) for i in r])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment