0

I have a script that inserts data from a DataFrame into a Teradata DB table example list:

0  1     2          3  \
0     2022-09-28 13:52:31.000192  U  1643652   2270.0   
1     2022-09-28 13:52:31.000192  U  1643653   2272.0 

I'm looking for a way to display each inserted row. If an error occurs on the first line and the insert stops, I want to know on which line the insert ended and output number row from dataframe:

1     2022-09-28 13:52:31.000192  U  1643653   2272.0 

I'm trying out the loop below but getting the error:

for i in session.execute(insert_import,import_batch):
    print(i)

udaExec = teradata.UdaExec(appName = "HelloWorld", version = "1.0", logConsole=False)
session = udaExec.connect(dataSourceName="Name",method="odbc",driver="Teradata Database ODBC Driver 16.20",charset="UTF8",system="TDSB14",username=''''''us'''''',password=''''''pw'''''',autocommit=True)
insert_import = """ insert into test values(?,?,?,?,?,?,?,?,?,?) """ 
import_batch = [tuple(x) for x in dtt.to_records(index=False)]
#session.executemany(insert_import,import_batch,batch=True)
for i in session.execute(insert_import,import_batch):
    print(i)

how to display insertable list line by line?

Serg
  • 93
  • 1
  • 10

0 Answers0