Perl to Python

Paul Malinowski paul.malinowski at wulfsberg.com
Tue Nov 27 00:45:17 CET 2001


Howdy,

I am relatively new to programming and very new to Python.
I have a number of Perl/CGI scripts on a Linux/Apache web
server that run queries to 
MS Access databases through an Openlink service running on
an NT server.  Works great!  I have been trying to do the 
same thing with Python and am not having much luck.  Would
it be to much to ask one of you Python guru's to help me
translate this from Perl to Python?  (I intentionally left
out the paths in the Perl environment variables to the 
OpenLink installed client on my Linux system to hide user 
names and such...)

Any help would be really appreciated!

Paul Malinowski

#!/usr/bin/perl

#Setting some environment variables.
$ENV{UDBCINI}="~openlinksw/bin/udbc.ini";
$ENV{ODBCINI}="~openlinksw/bin/odbc.ini";
$ENV{ODBCINSTINI}="~openlinksw/bin/odbcinst.ini";
$ENV{LD_LIBRARY_PATH}="$ENV{LD_LIBRARY_PATH}:~openlinksw/lib";
$ENV{SHLIB_PATH}="$ENV{SHLIB_PATH}:~openlinksw/lib";
$ENV{PATH}="$ENV{PATH}:~openlinksw/bin:~openlinksw/samples/ODBC";

#SQL query that runs qryModelSNforWeb in the warranty Access database.
$sql = "echo \"select *  from <Query in MS Access Database>;\" |
odbctest DSN=<OpenLink Definition to MS Access DataBase>";

if (!open(SQL,"$sql |")) {
    print "Unable to open connect to database<br>";
    exit 0;
}

if (open(SQL, "$sql |")) {
    chomp(@rawdata = <SQL>);
}



More information about the Python-list mailing list