Friday, August 14, 2009

Connecting to SQL Server in Python

http://pymssql.sourceforge.net/


import pymssql
conn = pymssql.connect(host='localhost', user='user', password='password', database='HOGE-DB')
cur = conn.cursor()
sql_string = "select * from tableName"
cur.execute(sql_string)
rows = cur.fetchall()
for row in rows:
    print row

No comments: