Reputation: 43830
I have a Perl script that interfaces with an existing database (type of database is unknown) through the DBI module, that I would like to access in python 2.6 on WinXP.
The Perl code is:
use DBI;
my $DSN = "DBI:Proxy:hostname=some.dot.com;port=12345;dsn=DBI:XXXX:ZZZZZ";
my $dbh = DBI->connect($DSN);
Can this be translated into a python equivalent?
Following an example at (Is there any pywin32 odbc connector documentation available? ), I've put together the following:
import odbc
DSN = "DBI:Proxy:hostname=some.dot.com;port=12345;dsn=DBI:XXXX:ZZZZZ"
db = odbc.odbc(DSN)
But I get the error:
dbi.operation-error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in LOGIN
UPDATE
It appears that another Perl module, DBD::Proxy is providing the actual interface to a Perl DBI::ProxyServer (server-side) implementation that handles the actual queries.
Can python be used to interface with the Perl-based DBI::ProxyServer?
http://metacpan.org/pod/DBD::Proxy
http://hell.org.ua/Docs/oreilly/weblinux/dbi/ch08_02.htm
Upvotes: 0
Views: 2188
Reputation: 5033
Your python script doesn't have to be a line by line translation of your Perl script.
Why not just use the Python DB-API compatible module for the database you want to access? For MySQL, use MySQLdb. For PostgreSQL, use PyGreSQL.
Or search Google for "YourDatabaseName + python"
Upvotes: 5