18

I know pyodbc is an older project and probably more featureful and robust, but is there anything about its design (based on components of compiled C code), that would make it preferable to a pure Python implementation, such as pypyodbc?

I do a lot of ETL work and am thinking of switching from a Linux/Jython/JDBC approach to Windows/Cygwin/Python/ODBC approach.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
Tony
  • 625
  • 1
  • 6
  • 17
  • From my experience with different databases JDBC drivers have less bugs than ODBC drivers. I think JDBC is more popular. I have also found that JDBC is easier to use. You can use it directly from Jython so stay with Jython and JDBC :-) – Michał Niklas Jan 24 '13 at 10:00
  • I would much prefer to connect from a Linux platform via JDBC, but my applications are written in Django and django-jython is outdated, which means the Django ORM is crippled for my ETL work. There is also the issue of compiling Python packages with C components. – Tony Jan 24 '13 at 16:38

1 Answers1

11

Potential advantages of pyodbc over pypyodbc by being written in C would be:

Potential advantages of pypyodbc over pyodbc by written in Python would be:

  • Less likely to contain C pointer issues
  • Slightly less likely to contain memory allocation issues
  • Simpler to maintain; a higher-level language means less lines of code
  • Much much easier to install without compilation issues which require a separate build for separate versions of Python, platform etc

Advantages of maturity:

  • Fewer bugs
  • More comprehensive coverage of features
  • Better handling of corner-cases

The maturity thing is largely dependent on pyodbc not being buggy. In my past experience (around 2016) that was not true and it had had a fair number of memory leak bugs etc. But since then pyodbc has been improved significantly and is now properly maintained.

The author's claim is that pypyodbc is a reimplementation of the pyodbc code in Python, and that would mean that the feature coverage should be equivalent. There may be some corner cases that have been less tried in the newer code though.

Disclaimer: I haven't yet tried pypyodbc

David Fraser
  • 6,475
  • 1
  • 40
  • 56
  • 3
    I was under the impression that pyodbc needed to be re-compiled each time a new version of Python is released. Certainly when I tried to install the latest version of pyodbc on my (Windows) machine that has Python 3.4 the pyodbc installer complained that it couldn't find Python 3.3. Rather than fiddling with it I just installed pypyodbc (via pip) and it works fine. Also, I've seen a number of cases here on SO where problems with pyodbc were solved by moving to pypyodbc. – Gord Thompson Apr 13 '15 at 20:47
  • I have had issues with ''utf-8 codec can't decode" type error in pyodbc that I do not get in pypyodbc – Keith Mar 26 '18 at 17:13
  • 1
    Things have changed in the last four years. See [this question](https://stackoverflow.com/q/57063181/2144390) for a more recent discussion. FWIW, I now use pyodbc. – Gord Thompson Jul 16 '19 at 20:27
  • Yes, it is true that pyodbc is now better maintained and has had good bugfixes. I've updated my answer to reflect this. – David Fraser Aug 19 '21 at 10:53