0

I have a working pyodbc connection to a i5/OS database and now I would like to use sqlalchemy.

According to these sites it should be possible:

I tried it with 3.5.2 as well as with a Python 2.7.12.

import pyodbc
import ibm_db_sa
from sqlalchemy import *

db = create_engine('ibm_db_sa+pyodbc://username:password@database/*local')

In Python2 I get:

return self.dbapi.connect(*cargs, **cparams)
sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

In Python3 I get:

connectors.extend(['%s=%s' % (k,v) for k,v in keys.iteritems()])
AttributeError: 'dict' object has no attribute 'iteritems'.

Could anyone confirm that it is even possible to connect a AS/400 i-Series and if so put me in the right direction. I tried a lot of different things. Thanks in advance.

Community
  • 1
  • 1
weinni2000
  • 41
  • 1
  • 6
  • What I bugs me is that in my working pyodbc connections I specify the driver (driver='{iSeries Access ODBC Driver}' ). – weinni2000 Nov 28 '16 at 14:03
  • The [third link](http://stackoverflow.com/questions/35461388/connecting-to-ibm-as400-server-for-database-operations-hangs) you provided already confirms that you can connect to the IBM i, and gives tips on how to do so. – John Y Nov 29 '16 at 14:44
  • The Python 3 error message is telling you that `keys` is a dictionary, and that dictionaries (in Python 3) do not have any `iteritems` attribute. (That attribute is in fact specific to Python 2 dictionaries.) So whatever module contains that piece of code was written specifically for Python 2. If you want to use it with Python 3, you will have to modify it. In this case, you would replace `iteritems()` with simply `items()`, but there may well be more Python-2-only code lurking in there. – John Y Nov 29 '16 at 14:52

0 Answers0