Skip to content

Instantly share code, notes, and snippets.

@dpritchett
Created March 24, 2011 13:40
Show Gist options
  • Save dpritchett/885069 to your computer and use it in GitHub Desktop.
Save dpritchett/885069 to your computer and use it in GitHub Desktop.
Sample pyodbc code to read a log table out of SQL Server
import pyodbc
cnxn = pyodbc.connect('DSN=production_rdmbs')
cursor = cnxn.cursor()
cursor.execute("SELECT [Trigger_Name] \
,[Table_Ready] \
,[Date_Modified] \
FROM triggers_table_name")
rows = cursor.fetchall()
def listLoggedTrigger(row):
print row[0] + "\t" + row[2].strftime('%c')
[listLoggedTrigger(r) for r in rows]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment