3

I am trying to get Django-pyodbc to work with DB2 on IBM i using the standard IBM i Access ODBC driver. I know there is a Django DB implementation supported by IBM, but that requires the DB2 Connect product, which is (for us) prohibitively expensive, whereas the included Access ODBC driver comes no-charge with the OS.

I have seen a question asked regarding django-pyodbc with iSeries ODBC, suggesting that it is possible, but I have found no way to get it to work: https://stackoverflow.com/questions/25066866/django-inspectdb-on-db2-database

My first question therefore is; has anybody succeeded in getting this setup to work? And if yes, can you share information on how you did it?

Thanks, Richard

Community
  • 1
  • 1
RichardX
  • 51
  • 3
  • I am wanting to do exactly this, for the same reasons you cite. Did you succeed? – W.Prins Aug 16 '16 at 16:01
  • No, unfortunately not. I gave up. The Django DB2 driver has been adapted for Python native on IBM i, but it doesn't work completely flawless yet. – RichardX Aug 18 '16 at 09:37
  • Right, thanks. Did you previously come across this question: http://stackoverflow.com/questions/35461388/connecting-to-ibm-as400-server-for-database-operations-hangs This relates the conversion of SQLAlchemy from the IBM DC driver to substituting PyODBC driver, which is kind of similar to the above but for SQLAlchemy. Anyway, long story short I've this afternoon spent time checking out that post and the ibm_db_sa package. It turns out this contains a pyodbc.py module with an AS400Dialect_pyodbc dialect class. – W.Prins Aug 18 '16 at 17:04
  • However it's not immediately obvious how to properly use this class instead of the default one (perhaps a case of my ignorance), some of the trouble may also be caused by Python 2/3 issues as the IBM code is Python 2 while (as it turned out) I was trying to make this work in Python 3.5.1. On the plus side, I eventually after some hacking managed to make SQLAlchemy at least retrieve data via the normal ODBC driver (and using Python 3), which I would suggest means it should be possible to do the same with Django etc. – W.Prins Aug 18 '16 at 17:08
  • If I recall correctly, the problem appears only when trying to use Django (I tried with 1.8). I didn't get past the initial migration of the project. Just making the connection and retrieving some data worked fine in plain Python 3. – RichardX Aug 22 '16 at 06:54
  • Thanks for the comment. In trying to make one of SQLA's reflection tools, https://pypi.python.org/pypi/sqlacodegen -- somewhat the equivalent of generating Djangos models.py) work, I also did run into further issues re Python 3 as you suggested - not sure if they were the same specific issues or not. I did however manage to fix them all, to the extent that I've now managed to successfully perform an SQLA reflection of the iSeries I'm working with. (Huge number of tables/classes.) I'll return to Django eventually and post further findings. – W.Prins Aug 22 '16 at 19:00

0 Answers0