使用sqlalchemy连接Teradata DB

时间:2018-08-24 04:25:26

标签: python sqlalchemy

我正在尝试使用Teradata连接到SqlAlchemy

下面是代码:

from sqlalchemy import create_engine

username = 'userName'
password = 'pass#word'
host = 'hostname'
query = 'sel count(*) from databaseName.tableName;'

link = 'teradata://'+ username +':'+ password +'@'+host+'/'+'?driver=/teradata/client/15.10/odbc_64/lib/tdata.so'

td_engine = create_engine(link)
result = td_engine.execute(query)

错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2074, in execute
    connection = self.contextual_connect(close_with_result=True)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2123, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2162, in _wrap_pool_connect
    e, dialect, self)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception_noconnection
    exc_info
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2158, in _wrap_pool_connect
    return fn()
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/pool.py", line 413, in connect
    return _ConnectionFairy._checkout(self, self._threadconns)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/pool.py", line 788, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/pool.py", line 532, in checkout
    rec = pool._do_get()
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/pool.py", line 1096, in _do_get
    c = self._create_connection()
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/pool.py", line 350, in _create_connection
    return _ConnectionRecord(self)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/pool.py", line 477, in __init__
    self.__connect(first_connect_check=True)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/pool.py", line 671, in __connect
    connection = pool._invoke_creator(self)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 106, in connect
    return dialect.connect(*cargs, **cparams)
  File "/ftp/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 410, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/ftp/lib/python2.7/site-packages/teradata/tdodbc.py", line 427, in __init__
    connectParams["DRIVER"] = determineDriver(dbType, driver)
  File "/ftp/lib/python2.7/site-packages/teradata/tdodbc.py", line 381, in determineDriver
    " Available drivers: {}".format(driver, ",".join(drivers)))
sqlalchemy.exc.InterfaceError: (teradata.api.InterfaceError) ('DRIVER_NOT_FOUND', "No driver found with name '/teradata/client/15.10/odbc_64/lib/tdata.so'.  Available drivers: composite70 ,composite70_2x ,composite70_x64 ,") (Background on this error at: http://sqlalche.me/e/rvf5)

请提出可能的问题。我给出了Teradata驱动程序的实际路径,甚至尝试将驱动程序更改为/teradata/client/15.10/odbc_64/libTeradata,但仍然出错,无法找到该驱动程序。

0 个答案:

没有答案