开发者

What are the most popular open source ODBC interfaces for python?

I was wondering 开发者_如何学运维what are the most popular open source obdc/database connection libraries are.

I've heard of pyodbc, but I wasn't sure how widely used it was.

Thanks


If you use Windows, then in popular Active State distribution you will find odbc module. I think it is part of pywin32 package. Of course pyodbc will be better if you do not use MS Windows. All you have to do is:

import odbc
connection = odbc.odbc('dsnname/user/passwd')

While pydobc connect string looks different you can made your program work with both libraries:

if '/' in connect_string:
    import odbc
    # dsnname/user/password
    _CONN = odbc.odbc(connect_string)
elif connect_string.startswith('Driver='):
    import pyodbc
    # Driver={PostgreSQL};Server=db-test;Port=5435;Database=dbname;Uid=user;Pwd=password;
    _CONN = pyodbc.connect(connect_string)


I would also like to point out turbodbc. It is open source, actively maintained, compatible with Python 2 and 3, and available for Linux, OSX, and Windows. You might want to give it a shot since it often improves on pyodbc's performance due to the use of bulk operations. It also offers built-in NumPy support, if you are into that kind of thing. Check out the official documentation, in particular the getting started guide.


http://wiki.python.org/moin/ODBC details some of the ODBC solutions for Python. pyodbc seems to be your best option for a few reasons:

  1. It appears to be the only open source option, having an MIT style license
  2. It's cross-platform

Sadly, I have no way of providing you much further information because Google Code is down, and that's where pyodbc is hosted (along with many others). It seems to be the closest to a standard solution, however.

Update

Google Code is back up and it seems to me from the project site that pyodbc is very actively contributed to and maintained, and it seems to be keeping up with Python, as a 3.x port is coming soon.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜