tags:

views:

36

answers:

2

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

A: 

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.

Rafe Kettler
A: 

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)
Michał Niklas