cancel
Showing results for 
Search instead for 
Did you mean: 

batch insert of tuples into HANA using HANA Client in SAP Data Intelligence

rajarshi_muhuri
Active Participant
0 Kudos

via python code , I can do batch insert to HANA table ( code sample below )

_list = []

# loop and add tuples to the _list 
_list.append( tuple ( ( value1, values2 , values3  )) )   
  
PARAMS = '?,?,?'     
SQL = f"insert into schema.table values ( {PARAMS})"
cursor.executemany(SQL , _SQL_TUPLE)

How can we achieve the same in HANA client

Accepted Solutions (1)

Accepted Solutions (1)

AndreasForster
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rajarshi, The hana_ml library has a nice feature to load data from Python to HANA. it uses the SAP HANA Python driver under the hood. Just turn your data into a Pandas dataframe and upload to a HANA table. It can create the target table, or just append the new rows. Just check with your Account Executive if your HANA license is allowing for this usage. https://help.sap.com/doc/1d0ebfe5e8dd44d09606814d83308d4b/2.0.05/en-US/html/hana_ml.dataframe.html#h...

import hana_ml.dataframe as dataframe
df_remote = dataframe.create_dataframe_from_pandas(connection_context = conn, 
                                                   pandas_df = df_data, 
                                                   table_name = 'TARGETTABLE',
                                                   force = True,
                                                   replace = False)

Answers (2)

Answers (2)

shaktik
Explorer
0 Kudos

Dear Rajshri,

Incase you want to use standard hana client operator - you can simply pass data as string (CSV format) to the HANA table. Please make sure that you use data port of hana client

push data.

Please note the SQL port can be also used incase you want to insert data using Insert SQL

Thanks

andy_yin
Explorer
0 Kudos

Hi Rajarshi,

This blog SAP Data Intelligence: Insert JSON Data into SAP HANA or SAP Data Warehouse Cloud should be helpful for your question. You can also refer to the sample graph named "Load Files into HANA" provided by SAP Data Intelligence.

Regards,
/Andy