Open Diyago opened 6 years ago
My problem easily fixed my using another library:
from turbodbc import connect
driver="Teradata Database ODBC Driver 16.10"
connection = connect(driver=driver,
server=ip,
DBCName='.com',
uid=username,
pwd=password)
cursor = connection.cursor()
query = 'sel * from tb'
cursor.execute(query)
data = pd.DataFrame(cursor.fetchallnumpy()) #to get pandas dataframe
data.to_csv('tb.csv')
cursor.close()
Is this library actually supported?
Note that in the second example you are avoiding pd.read_sql
entirely, suggesting this method might be causing the problem.
I suggest fetching the rows from the database using the Teradata library (via cursor.execute(query).fetchall()
), then creating a dataframe using the list of returned Row
objects. Depending on what the pandas constructor expects, you may need to access the .columns
and .values
of individual rows.
Evn: Python 3.6, windows 10,
Connection:
To reproduce:
How to fix this?