Skip to content

Instantly share code, notes, and snippets.

@justinlewis
Created February 7, 2013 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinlewis/4732805 to your computer and use it in GitHub Desktop.
Save justinlewis/4732805 to your computer and use it in GitHub Desktop.
Connect to a SQL Server database with pyodbc: http://www.easysoft.com/developer/languages/python/pyodbc.html
#### Just some notes for the future.
import pyodbc
connect = pyodbc.connect('DRIVER={SQL Server};SERVER=your_host;DATABASE=your_database;UID=username;PWD=password')
cursor = connect.cursor()
print "Connection to TRIPS database established"
cursor.execute("select * from YOUR_TABLE;")
for row in cursor.fetchall():
print row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment