Python Forum

Full Version: Issue while inserting data into Teradata via python dataframe
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All
I am using below code to insert data into terdata table.
I am getting below error:
Output:
ProgrammingError: ('42000', "[42000] [Teradata][ODBC Teradata Driver][Teradata Database] Syntax error, expected something like '(' between the 'type' keyword and '='. (-3707) (SQLPrepare)") During handling of the above exception, another exception occurred:
for each in df:
    df1= each[each.TRAN_STMT_DESC.str.contains("SUPERBOOK")]
    df1['TRAN_STMT_DESC']='SUPERBOOK'
    #total=df1.groupby(['TRAN_STMT_DESC']).sum()
    print(df1.head())
Want to insert df1 data into table..

my code:
df1.to_sql(name='KLMD_SRM.PYTHON_LKP' ,con=conn_klm, if_exists='replace', index=False)

my connection settings:
td_userID = getpass.getpass('Enter User id')
td_password = getpass.getpass('Enter pwd')
conn_klm = pyodbc.connect('DSN=klm-LDAP;UID='+str(td_userID)+';PWD='+str(td_password))
del td_password, td_userID
conn_klm
conn_klm.autocommit = True 
curs = conn_klm.cursor()
HERE MY TABLE NAME :'PYTHON_LKP'
SCHEMA NAME : 'KLMD_SRM'

Please can one help me on this.

Thanks
My first impression is that this line:

df1= each[each.TRAN_STMT_DESC.str.contains("SUPERBOOK")]
is the problem. The "str" attribute could cause conflation between the attribute name and the string type. Still, it would be helpful to see the full traceback.
I am abel to print df1...

print(df1.head())
so there is data in df1.