Linux上python的本机ODBC访问? [英] Native ODBC access for python on linux?

查看:59
本文介绍了Linux上python的本机ODBC访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力让Python通过ODBC与MySQL交谈。我在Windows上启动了
,由于ODBC的东西很好地运行得很顺利

显然至少在Windows上是Python原生的(我已经

跟随马克·哈蒙德的第13章,在win32上写了。)


但是现在我正在尝试在linux上做相同的东西(Fedora Core 3)用

python 2.3.5和mysql。我想坚持使用python原生的软件包,而不是依靠外部资源(例如,MySQLdb

和mxODBC)。这是可能的,还是我必须使用第三方作品?/ b $ b在Linux下使用ODBC和Python?

顺便说一句,我只使用ODBC来访问db',期间。我从来没有使用过
,例如MySQL用于处理MySQL数据库的API。我很好看,如果有人有任何例子

(python,c或其他),那么看起来很好看。


提前感谢您的帮助。

-Bill

I''m getting my feet wet with making Python talk to MySQL via ODBC. I
started on Windows, and it went smoothly enough due to the ODBC stuff
that apparently is native to Python at least on windows (I''ve been
following ch. 13 of Mark Hammond''s py on win32 book).

But now I''m trying to do equivalent stuff on linux (Fedora Core 3) with
python 2.3.5 and mysql. I''d like to stick with packages that are
native to python, rather than relying on external stuff (e.g., MySQLdb
and mxODBC). Is this possible, or do I have to use 3rd party pieces to
use ODBC with Python under linux?
As an aside, I''ve only used ODBC to access db''s, period. I''ve never
used, for example, MySQL''s API for working with a MySQL db. I''m
curious to see what that looks like, if anyone has any examples
(python, c, or otherwise).

Thanks in advance for any help.
-Bill

推荐答案

ODBC是一个香草在程序

和数据库之间放置一个层的接口。理论上,这将允许您编写一个支持ODBC兼容数据库的

程序,并且它可以与任何一个一起工作

。在实践中,似乎这并不像每个人所希望的那样工作(性能经常是一个问题)ODBC接口和时间/日期处理的性能通常是...是一个

问题)。


有些人为Linux提供ODBC驱动程序,但通常是

他们习惯于回复从Linux框到MSSQL服务器或其他Windows

应用程序。


原生界面几乎总是表现更好,而且b $ b支持更多功能因为ODBC基本上是最低常见的分母方法。本机API可以提供对特定数据库(甚至唯一)功能的访问权限


恕我直言 - 用于Linux上的Python到MySQL使用本机接口是b / b
的路要走。


拉里贝茨

ca ******** @ gmail.com 写道:
ODBC is a vanilla interface that puts a layer between the program
and the database. In theory, this would allow you to write a
program that supports ODBC compliant databases and it would work
with any of them. In practice it always seems like this doesn''t
work as well as everyone had hoped (performance is quite often a
problem with ODBC interface and time/date handling can be an
issue).

There are people that provide ODBC drivers for Linux but normally
they are used to communcate back to MSSQL servers or other Windows
applications from Linux box.

The native interfaces are almost always better performing and
support more features because ODBC is basically a lowest common
denominator approach. The native API can provide access to all
the (even unique) features of the particular database

IMHO-For Python to MySQL on Linux use the native interface is
the way to go.

Larry Bates

ca********@gmail.com wrote:
我正在努力让Python与MySQL交谈ODBC。我开始在Windows上运行,由于ODBC的东西显而易见,它显得非常流行,至少在Windows上显然是Python原生的(我已经跟随了Mark Hammond的第13章)在win32上写了py。)

但是现在我正在尝试使用
python 2.3.5和mysql在linux(Fedora Core 3)上做相同的东西。我想坚持使用python原生的软件包,而不是依赖外部资源(例如,MySQLdb
和mxODBC)。这是可能的,还是我必须使用第三方作品在linux下使用ODBC和Python?

顺便说一句,我只使用ODBC来访问db'' ,期间。我从来没有使用MySQL的API来处理MySQL数据库。我很好奇,看看有什么样的,如果有人有任何例子
(python,c或其他)。

提前感谢您的帮助。
-Bill
I''m getting my feet wet with making Python talk to MySQL via ODBC. I
started on Windows, and it went smoothly enough due to the ODBC stuff
that apparently is native to Python at least on windows (I''ve been
following ch. 13 of Mark Hammond''s py on win32 book).

But now I''m trying to do equivalent stuff on linux (Fedora Core 3) with
python 2.3.5 and mysql. I''d like to stick with packages that are
native to python, rather than relying on external stuff (e.g., MySQLdb
and mxODBC). Is this possible, or do I have to use 3rd party pieces to
use ODBC with Python under linux?
As an aside, I''ve only used ODBC to access db''s, period. I''ve never
used, for example, MySQL''s API for working with a MySQL db. I''m
curious to see what that looks like, if anyone has any examples
(python, c, or otherwise).

Thanks in advance for any help.
-Bill



我同意拉里的观点。我发现通过在我自己的类中适当地抽象数据库

连接代码,我可以使用任何符合DB-API的

Python模块连接到各种数据库。我用例如
cxOracle连接到Oracle和kinterbasdb连接到firebird。我还没有尝试过本地连接到MySQL,但是我不认为它会有什么不同。


Grig

I concur with Larry. I find that by properly abstracting the database
connection code in my own class, I can then use any DB-API-compliant
Python module to connect to a variety of databases. I use for example
cxOracle to connect to Oracle and kinterbasdb to connect to firebird. I
haven''t tried connecting to MySQL natively yet, but I don''t think it
would be any different.

Grig




< ca ******** @ gmail.com>在消息中写道

news:11 ********************** @ g14g2000cwa.googlegr oups.com ...

<ca********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
我正在努力让Python通过ODBC与MySQL交谈。我开始在Windows上运行,由于ODBC的东西显而易见,它显得非常流行,至少在Windows上显然是Python原生的(我已经跟随了Mark Hammond的第13章)在win32上写了py。)

但是现在我正在尝试使用
python 2.3.5和mysql在linux(Fedora Core 3)上做相同的东西。我想坚持使用python原生的软件包,而不是依赖外部资源(例如,MySQLdb
和mxODBC)。这是可能的,还是我必须使用第三方作品在linux下使用ODBC和Python?

顺便说一句,我只使用ODBC来访问db'' ,期间。我从来没有使用MySQL的API来处理MySQL数据库。我很好奇,看看有什么样的,如果有人有任何例子
(python,c或其他)。

提前感谢您的帮助。
-Bill
I''m getting my feet wet with making Python talk to MySQL via ODBC. I
started on Windows, and it went smoothly enough due to the ODBC stuff
that apparently is native to Python at least on windows (I''ve been
following ch. 13 of Mark Hammond''s py on win32 book).

But now I''m trying to do equivalent stuff on linux (Fedora Core 3) with
python 2.3.5 and mysql. I''d like to stick with packages that are
native to python, rather than relying on external stuff (e.g., MySQLdb
and mxODBC). Is this possible, or do I have to use 3rd party pieces to
use ODBC with Python under linux?
As an aside, I''ve only used ODBC to access db''s, period. I''ve never
used, for example, MySQL''s API for working with a MySQL db. I''m
curious to see what that looks like, if anyone has any examples
(python, c, or otherwise).

Thanks in advance for any help.
-Bill




我们有Linux / Apache / MySQL服务器。我们使用ODBC驱动程序使用VB编写

Windows客户端。我只是将ODBC理解为将Linux / Apache / MySQL与Microsoft世界的术语联系起来的手段。 ODBC提供

作为这两个外星系统之间的翻译。


虽然我听说Linux上有关ODBC驱动程序的传言,但我承认我不是/>
了解需要。当然你可以在任何Linux机器上使用Python和MySQLdb模块

并在服务器上查询。只要MySQL

服务器接受你的IP / usr / pwd,它就会响应你传递给它的SQL。

Python。


IOW - 谁/什么需要ODBC驱动程序?

Thomas Bartkus



We have a Linux/Apache/MySQL server. We use the ODBC driver to write
Windows clients using VB. I only understand ODBC as a means to bring the
Linux/Apache/MySQL to speaking terms with the Microsoft world. ODBC serves
as the translator between these 2 alien systems.

Although I hear rumors about ODBC drivers on Linux, I confess I don''t
understand the need. Certainly you can use Python with the MySQLdb module
from any Linux machine and query away at the server. As long as the MySQL
server accepts your IP/usr/pwd, it will respond to the SQL you pass it from
Python.

IOW - who/what needs an ODBC driver here?
Thomas Bartkus


这篇关于Linux上python的本机ODBC访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆