Python 相当于 perl 的 dbi/DBD::Proxy 访问? (Perl DBI/DBD::Python 代理)

发布于 2024-07-19 15:57:48 字数 1318 浏览 5 评论 0原文

我有一个 Perl 脚本,它通过 DBI 模块与现有数据库(数据库类型未知)交互,我想在 WinXP 上的 python 2.6 中访问该脚本。

Perl 代码是:

use DBI;
my $DSN = "DBI:Proxy:hostname=some.dot.com;port=12345;dsn=DBI:XXXX:ZZZZZ";
my $dbh = DBI->connect($DSN);  

Can this betranslated into a python equals?

按照以下示例(是否有任何 pywin32 odbc 连接器文档可用?),我已经将以下内容放在一起:

import odbc
DSN = "DBI:Proxy:hostname=some.dot.com;port=12345;dsn=DBI:XXXX:ZZZZZ"
db = odbc.odbc(DSN)

但我收到错误:

dbi.operation-error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in LOGIN

UPDATE

看来另一个 Perl 模块 DBD::Proxy 正在为 Perl DBI 提供实际接口::ProxyServer(服务器端)实现,处理实际查询。

python 可以用来与基于 Perl 的 DBI::ProxyServer 进行交互吗?

http://metacpan.org/pod/DBD::Proxy

http://hell.org.ua/Docs/oreilly/weblinux/dbi/ch08_02.htm

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

森林很绿却致人迷途 2024-07-26 15:57:49

sqlalchemy 非常不错。

sqlalchemy is pretty nice.

葵雨 2024-07-26 15:57:49

您的 Python 脚本不必是 Perl 脚本的逐行翻译。

为什么不直接为您的数据库使用 Python DB-API 兼容模块想要访问? 对于 MySQL,请使用 MySQLdb。 对于 PostgreSQL,请使用 PyGreSQL

或者在 Google 中搜索“YourDatabaseName + python”

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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文