我正在使用SQLAlchemy来通过此功能连接到Teradata数据库:
from sqlalchemy import create_engine
cnx = create_engine(engine+"://"+username+":"+password+"@"+host)
但是我遇到了这个错误:
Traceback (most recent call last):
File "<stdin>",line 1,in <module>
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/__init__.py",line 479,in create_engine
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/strategies.py",line 98,in create
File "build/bdist.linux-x86_64/egg/sqlalchemy_teradata/dialect.py",line 129,in create_connect_args
File "build/bdist.linux-x86_64/egg/sqlalchemy_teradata/data_type_converter.py",line 13,in __init__
TypeError: super() argument 1 must be type,not classobj
这对于python 2.7.11来说对我来说是完美的,但是现在在python 2.7.13上执行时,我什至不了解错误。
FI:
data_type_converter.py的外观如下:
from teradata.datatypes import DefaultDataTypeConverter
class TDDataTypeConverter(DefaultDataTypeConverter):
def __init__(self,*args,**kwargs):
super(TDDataTypeConverter,self).__init__(*args,**kwargs)
def _process_data_type(self,dataType):
if 'INTERVAL' in dataType:
return dataType.replace('_',' ')
return dataType
def convertvalue(self,dbType,dataType,typeCode,value):
dataType = self._process_data_type(dataType)
return super(TDDataTypeConverter,self).convertvalue(
dbType,value)
当连接到Postgres数据库时,create_engine()函数也可以工作