buttermilk
buttermilk

Reputation: 375

Importing a pandas dataframe into Teradata database

I am attempting to import an Excel file into a new table in a Teradata database, using SQLAlchemy and pandas.

I am using the pandas to_sql function. I load the Excel file with pandas and save it as a dataframe named df. I then use df.to_sql and load it into the Teradata database.

When using the code: df.to_sql('rt_test4', con=td_engine, schema='db_sandbox')

I am prompted with the error: DatabaseError: (teradata.api.DatabaseError) (3534, '[42S11] [Teradata][ODBC Teradata Driver][Teradata Database] Another index already exists, using the same columns and the same ordering. ') [SQL: 'CREATE INDEX ix_db_sandbox_rt_test4_index ("index") ON db_sandbox.rt_test4']

When I try this and use Teradata SQL Assistant to see if the table exists, I am prompted with selecting txt or unicode for each column name, and to pick a folder directory. A prompt titled LOB information pops open and I have to select if it's UTF or unicode, and a file directory. Then it loads and all the column titles populate, but they are left as empty fields. Looking for some direction here, I feel I've been spinning my wheels on this.

Upvotes: 1

Views: 1865

Answers (1)

buttermilk
buttermilk

Reputation: 375

I solved it! Although I do not know why, I'm hoping someone can explain:

tf.to_sql('rt_test4', con=td_engine, schema='db_sandbox', index = False, dtype= {'A': CHAR, 'B':Integer})

Upvotes: 1

Related Questions