Error 3707 when trying to write a pandas data frame to teradata

Database
New Member

Error 3707 when trying to write a pandas data frame to teradata

Hi all,

 

I've established a connection from my Jupyter notebook to Teradata with sqlalchemy. The connection works and I can query data with the below code:

td_engine = create_engine('teradata://' + user + ':' + pwd + '@' + host + '/' + '?authentication=LDAP')

sql = '''
 SELECT *
 FROM SCHEMA.TABLE_NAME
 SAMPLE 100;
 '''

conn = td_engine.connect()
conn.execute(sql)
conn.close()

However, I seem to be unable to write a pandas data frame to Teradata. This is the code I used to try to write an empty data frame:

td_engine = create_engine('teradata://' + user + ':' + pwd + '@' + host + '/' + '?authentication=LDAP')

df = pd.DataFrame()

df.to_sql(name="TABLE_NAME", schema = "SCHEMA", con=td_engine, index = False) 

This is the error message I get:

DatabaseError: (teradata.api.DatabaseError) (3707, "[42000] [Teradata][ODBC Teradata Driver][Teradata Database](-3707)
Syntax error, expected something like a 'CHECK' keyword between '(' and ')'.") 
[SQL: '\nCREATE TABLE "SCHEMA"."TABLE_NAME"  (\n)\n\n'] 
(Background on this error at: http://sqlalche.me/e/4xp6)

I've spent a whole day on this already and am no wiser... Can anyone help? I'd highly appreciate any input!

 

Thanks!

 

Best regards,

Tobes

 

 

1 REPLY 1
Highlighted
Teradata Employee

Re: Error 3707 when trying to write a pandas data frame to teradata

You can't write a totally empty DataFrame. At least one column is required