Connecting to SQL Server from UNIX

Benji York benji at
Sun Oct 24 03:22:31 CEST 2004

yuba at wrote:
> Is it possible for me to connect to a MS SQL-Server from a UNIX box via Python
> (2.3)? 

Check out ODBTP ( and my (alpha) Python DB 
API 2.0 bindings for it (

You install the ODBTP service on a Windows machine (the one with SQL 
Server or a different one) and use the ODBTP client to connect to it 
from Unix, Linux, Windows, etcetera.

Here's a small example program:

import odbtpapi

connectString = 'Driver=SQL Server;Server=;UID=sa;PWD=thepassword;'
connection = odbtpapi.connection(connectString, server='')
cursor = connection.cursor()
sql = 'select * from MyDatabase..MyTable where someColumn = ?'
cursor.execute(sql, ['A Value'])
for row in cursor.fetchall():
     print row

print cursor.description

Benji York
benji at

More information about the Python-list mailing list