Python 相当于 perl 的 dbi/DBD::Proxy 访问? (Perl DBI/DBD::Python 代理)
我有一个 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 进行交互吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
sqlalchemy 非常不错。
sqlalchemy is pretty nice.
您的 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"