I've done more research on this topic. There's a lot out there about
using MSSQL with SA, but next to nothing about using ibm_db_sa or
specifying drivers.

I have pyodbc installed. I downloaded IBM's ODBC zip file, and I've
put db2odbc64.dll in my project folder, but don't know how to point SA
or pyodbc to it. I've tried several versions of
"?driver="db2odbc64.dll"" appended to my connection string, but I keep
getting an error: "data source not found and no default driver
specified". It doesn't even time out anymore, it just errors out
immediately. I've also tried "ibm_db_sa+pyodbc://" to start the
string, but that fails too.

This *must* be a simple thing, but I can't work out what to do, and
Google is failing me. If anyone has any ideas, I'd greatly appreciate
hearing them. Thanks, and sorry to keep bugging the list about this. I
just have no other options at the moment and I need to get this
working soon.

On 2/11/16, Alex Hall <ah...@autodist.com> wrote:
> I think I'm confused. Isn't Pyodbc an alternative to SQLAlchemy? If
> not, how would the two work together? I just looked through the
> 'Getting Started' and 'API' docs for Pyodbc, and I don't see any
> examples. I found some samples online of people using the two
> together, but I don't quite follow how the process works. Thanks.
>
> On 2/10/16, Jaimy Azle <jaimy.a...@gmail.com> wrote:
>> Connecting to AS400 from native ibm_db_dbi driver would need db2 connect
>> which is a separated product from IBM. Use the ibm_db_sa pyodbc driver
>> instead, or jdbc (jython) if you don't have db2 connect installed on your
>> machine.
>>
>> Salam,
>>
>> -Jaimy
>> On Feb 11, 2016 01:50, "Alex Hall" <ah...@autodist.com> wrote:
>>
>>> 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:passw...@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.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "sqlalchemy" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an
>>> email to sqlalchemy+unsubscr...@googlegroups.com.
>>> To post to this group, send email to sqlalchemy@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/sqlalchemy.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sqlalchemy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sqlalchemy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sqlalchemy@googlegroups.com.
>> Visit this group at https://groups.google.com/group/sqlalchemy.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to