Python CGI and Accessing MS QL Server Database

Paul E. Bible pbible at home.com
Mon Jan 24 19:33:12 EST 2000


How about trying mxODBC
(http://starship.python.net/crew/lemburg/mxODBC.html).
I found that it's quite easy to install and works great.  Besides, the Win32
ODBC module, according
to the Python Website, is not currently being maintained by anyone.

Using mxODBC, I found that the following line will create a connection to a
database within a CGI script:

 # Open connect to Database via ODBC
 db = Odbc.Windows.DriverConnect('DRIVER={Microsoft ODBC for
Oracle};SERVER=Test;UID=userid;PWD=password;')

Obviously, I'm using the ODBC driver for Oracle, so replace this driver with
SQL Server.

Good Luck,
Paul

"Navtej Riyait" <Navtej.Riyait at ukgateway.net> wrote in message
news:86ioek$iek$1 at lure.pipex.net...
> Hello,
>
> I am trying to create a little test web application in python/HTML using
> IIS. I have setup IIS so that .cgi scripts are sent to the python
> interpreter. I am trying to access a SQL Server database, 'pubs' (using
> Python DB APIs). I am importing odbc, dbi in my script. Database access
> works fine when I run a dbtest script at the command line, but the same
bit
> of code gives an error when run in the .cgi script. It is not finding the
> data source name (DSN). I have set up the DSN in the ODBC Driver Manager
> correctly.
>
> I can't see what environment parameters to set to get the .cgi python
script
> to access the 'pubs' database. Can anyone help ?
>
>
> Thanks
>
>
>





More information about the Python-list mailing list