Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Connecting to SQL Server from UNIX

8 views
Skip to first unread message

yu...@conwaycorp.net

unread,
Oct 22, 2004, 2:39:05 PM10/22/04
to pytho...@python.org

Hello-

Is it possible for me to connect to a MS SQL-Server from a UNIX box via Python
(2.3)? I'm assuming I would need a driver, but I looked on microsoft.com and
could not find anything. Anyone out there ever try to do this?

Thanks
--greg


-----------------------------------------------------------------------------
This message was sent using Conway Corporation WebMail -- www.conwaycorp.net

Diez B. Roggisch

unread,
Oct 22, 2004, 2:48:29 PM10/22/04
to
yu...@conwaycorp.net wrote:

>
> Hello-
>
> Is it possible for me to connect to a MS SQL-Server from a UNIX box via
> Python
> (2.3)? I'm assuming I would need a driver, but I looked on microsoft.com
> and
> could not find anything. Anyone out there ever try to do this?

No surprise - microsoft wont do that for you...


What you need is unix-odbc, the freedts-driver and pyodbc - google for
them, and use the latest versions.

--
Regards,

Diez B. Roggisch

Benji York

unread,
Oct 23, 2004, 9:22:31 PM10/23/04
to pytho...@python.org, yu...@conwaycorp.net
yu...@conwaycorp.net wrote:
> Is it possible for me to connect to a MS SQL-Server from a UNIX box via Python
> (2.3)?

Check out ODBTP (http://odbtp.sourceforge.net/) and my (alpha) Python DB
API 2.0 bindings for it (http://benjiyork.com/odbtp.html).

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=10.0.0.1;UID=sa;PWD=thepassword;'
connection = odbtpapi.connection(connectString, server='10.0.0.2')
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
be...@benjiyork.com

0 new messages