Hello list,
I sent this to the ibm_db list yesterday, but no one has responded
yet. Since it's as much ibm_db as SA, I thought I'd try here as well
in case any of you have used an AS400 before. I have ibm_db,
ibm_db_sa, the latest sqlalchemy, and Python 2.7 (latest) installed. I
can talk to SQLite with no trouble, it's talking to this 400 that
won't work. Anyway...
I'm finally ready to hook my app to the 400 instead of the local
SQLite database I've been using for testing. Here's my simple script:
import globals
import logging
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
#set up the sqlalchemy objects
dbEngine = create_engine('ibm_db_sa://
username:pass...@mysite.com:8471/database')
Session = sessionmaker(bind = dbEngine) #note that's a capital s on Session
session = Session() #lowercase s
base = declarative_base()
def getAllTables():
dbInspector = inspect(dbEngine)
for table in dbInspector.get_table_names():
print table
getAllTables()
When I run that, it waits thirty seconds or so, then tells me there
was an error. I'll paste the entire traceback below. Sorry in
advance--it's pretty long.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\admin\Dropbox\Autodist\jobs>c:\python27\python.exe DBInterface2.py
Traceback (most recent call last):
File "DBInterface2.py", line 24, in <module>
getAllTables()
File "DBInterface2.py", line 18, in getAllTables
dbInspector = inspect(dbEngine)
File "c:\python27\lib\site-packages\sqlalchemy\inspection.py", line 63, in ins
pect
ret = reg(subject)
File "c:\python27\lib\site-packages\sqlalchemy\engine\reflection.py", line 139
, in _insp
return Inspector.from_engine(bind)
File "c:\python27\lib\site-packages\sqlalchemy\engine\reflection.py", line 135
, in from_engine
return Inspector(bind)
File "c:\python27\lib\site-packages\sqlalchemy\engine\reflection.py", line 109
, in __init__
bind.connect().close()
File "c:\python27\lib\site-packages\sqlalchemy\engine\base.py", line 2018, in
connect
return self._connection_cls(self, **kwargs)
File "c:\python27\lib\site-packages\sqlalchemy\engine\base.py", line 72, in __
init__
if connection is not None else engine.raw_connection()
File "c:\python27\lib\site-packages\sqlalchemy\engine\base.py", line 2104, in
raw_connection
self.pool.unique_connection, _connection)
File "c:\python27\lib\site-packages\sqlalchemy\engine\base.py", line 2078, in
_wrap_pool_connect
e, dialect, self)
File "c:\python27\lib\site-packages\sqlalchemy\engine\base.py", line 1405, in
_handle_dbapi_exception_noconnection
exc_info
File "c:\python27\lib\site-packages\sqlalchemy\util\compat.py", line 200, in r
aise_from_cause
reraise(type(exception), exception, tb=exc_tb)
File "c:\python27\lib\site-packages\sqlalchemy\engine\base.py", line 2074, in
_wrap_pool_connect
return fn()
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 318, in unique_c
onnection
return _ConnectionFairy._checkout(self)
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 713, in _checkou
t
fairy = _ConnectionRecord.checkout(pool)
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 480, in checkout
rec = pool._do_get()
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 1060, in _do_get
self._dec_overflow()
File "c:\python27\lib\site-packages\sqlalchemy\util\langhelpers.py", line 60,
in __exit__
compat.reraise(exc_type, exc_value, exc_tb)
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 1057, in _do_get
return self._create_connection()
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 323, in _create_
connection
return _ConnectionRecord(self)
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 449, in __init__
self.connection = self.__connect()
File "c:\python27\lib\site-packages\sqlalchemy\pool.py", line 607, in __connec
t
connection = self.__pool._invoke_creator(self)
File "c:\python27\lib\site-packages\sqlalchemy\engine\strategies.py", line 97,
in connect
return dialect.connect(*cargs, **cparams)
File "c:\python27\lib\site-packages\sqlalchemy\engine\default.py", line 385, i
n connect
return self.dbapi.connect(*cargs, **cparams)
File "c:\python27\lib\site-packages\ibm_db-2.0.6-py2.7.egg\ibm_db_dbi.py", lin
e 588, in connect
raise _get_exception(inst)
sqlalchemy.exc.OperationalError: (ibm_db_dbi.OperationalError) ibm_db_dbi::Opera
tionalError: [IBM][CLI Driver] SQL30081N A communication error has been detecte
d. Communication protocol being used: "TCP/IP". Communication API being used: "
SOCKETS". Location where the error was detected: "[IP of the 400
server]". Communicatio
n function detecting the error: "connect". Protocol specific error code(s): "10
060", "*", "*". SQLSTATE=08001\r SQLCODE=-30081
(I took out the actual IP). I'm not sure what most of that means, but
it looks like I can't connect to the 400 for some reason. Bad
credentials or something could be it, I suppose, but I'm using what my
work told me to use. I wondered if anyone here could spot the problem
before I go chasing different login details that I don't actually
need. Thanks in advance for any help.