[DB-SIG] Connecting to Microsoft SQL server from Python

M.-A. Lemburg mal@lemburg.com
Mon, 20 Sep 1999 19:53:01 +0200

Hrvoje Niksic wrote:
> In the company where I'll soon work, there is an NT machine running
> Microsoft SQL Server 6.5.  Next to it is a Linux box that runs
> programs that connect to the database.  I'd like to connect to the
> database using Python.
> At this time all the programs that connect to the database are written
> in Perl, using a module that works with the Sybase development
> library (ctlib).  The library connects to the Sybase driver installed
> on the NT machine, which in turn connects to the MS SQL server.
> This works nicely, but I'd rather use Python.  I thought the Sybase
> stuff was ODBC-driven, so I tried to use mxODBC, but it wouldn't
> compile -- it seems that the Sybase Linux library doesn't come with
> the ODBC API.  I tried Peter Godman's Sybase module, but it didn't
> seem usable.
> I guess I could write a new module from scratch based on the Perl
> module, but that would take a lot of time, as I know very little about
> the Python internals.
> So, my questions are:
> * Is there an ODBC library that can connect to the Microsoft SQL
>   server on a remote machine?  Does mxODBC work with it?

You could try one of the ODBC driver construction sets available
from InterSolv and OpenLink. The EasySoft ODBC bridge should also
work. Links etc. are on the mxODBC web-page.
> * Is there a Python module that can connect to the Microsoft SQL
>   server, with or without ODBC?

Don't know, but there is something interesting out there:
Perhaps someone has already conquered this protocol...

> * Is there another way to approach the problem?

Use RPC to transfer the queries to the NT Server and use the
SQL Server ODBC drivers there. Should be easy to do in Python.

> Help would be *much* appreciated.  I'd hate spend several years of my
> life coding Perl, or having to write wrappers around Perl functions in
> order to use them from Python.

Marc-Andre Lemburg
Y2000:                                                   102 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/