Perl to Python

Eyal Lotem eyal at hyperroll.com
Wed Nov 28 17:04:11 EST 2001


> #!/usr/bin/perl
#!/usr/bin/python

> #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";

#Setting some environment variables.
os.environ["UDBCINI"]="~openlinksw/bin/udbc.ini"
os.environ["ODBCINI"]="~openlinksw/bin/odbc.ini"
os.environ["ODBCINSTINI"]="~openlinksw/bin/odbcinst.ini"
os.environ["LD_LIBRARY_PATH"]="$ENV{LD_LIBRARY_PATH}:~openlinksw/lib"
os.environ["SHLIB_PATH"]="$ENV{SHLIB_PATH}:~openlinksw/lib"
os.environ["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>";
> 

#SQL query that runs qryModelSNforWeb in the warranty Access database.
import odbc # isntead of running odbctest, use the odbc Python module
result = odbc.odbc(<OpenLink Definition to MS Access 
DataBase>).cursor().exec(<Query in MS Access Database>)

> if (open(SQL, "$sql |")) {
>     chomp(@rawdata = <SQL>);
> }
# instead of chomping the reuslt, just print it as a tuple
print result # should be a tuple of the reuslts, iirc


You will need to get the odbc module, but I'm pretty sure this is how I 
recall it works. Hope it helps.




More information about the Python-list mailing list