monkut
monkut

Reputation: 43830

Python equivalent of perl's dbi/DBD::Proxy access? (Perl DBI/DBD::Proxy for Python)

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

Answers (2)

si28719e
si28719e

Reputation: 2165

sqlalchemy is pretty nice.

Upvotes: 0

Seun Osewa
Seun Osewa

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

Related Questions