Python Forum
Issue while inserting data into Teradata via python dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue while inserting data into Teradata via python dataframe
#1
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
Reply
#2
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.
Reply
#3
I am abel to print df1...

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Filter data into new dataframe as main dataframe is being populated cubangt 8 923 Oct-23-2023, 12:43 AM
Last Post: cubangt
  python script for inserting rows into hbase table lravikumarvsp 7 7,013 Mar-24-2023, 04:44 AM
Last Post: parth_botadara
  pandas dataframe into csv .... exponent issue mg24 10 1,708 Jan-20-2023, 08:15 PM
Last Post: deanhystad
  Issue in writing sql data into csv for decimal value to scientific notation mg24 8 2,879 Dec-06-2022, 11:09 AM
Last Post: mg24
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 1,306 Nov-08-2022, 07:16 PM
Last Post: marlonbown
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,560 Jul-25-2022, 03:19 PM
Last Post: deanhystad
  Seeing al the data in a dataframe or numpy.array Led_Zeppelin 1 1,111 Jul-11-2022, 08:54 PM
Last Post: Larz60+
  Need help formatting dataframe data before saving to CSV cubangt 16 5,531 Jul-01-2022, 12:54 PM
Last Post: cubangt
  Python issue - Data science - Help is needed yovel 2 1,969 Jul-29-2021, 04:27 PM
Last Post: yovel
  Reading data to python: turn into list or dataframe hhchenfx 2 5,280 Jun-01-2021, 10:28 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020