cancel
Showing results for 
Search instead for 
Did you mean: 

How to load an image into CLOB field

former_member212706
Participant
0 Kudos

Dear Experts,

     I would like to load an image into a CLOB filed in a table. Please guide me as to how this can be done.

Thanks in Advance!!!

Rajesh.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184768
Active Contributor
0 Kudos

Hi Rajesh,

Do you mean CLOB or BLOB to load the image. CLOB is character Large Object. I think you mean Binary Large Object (BLOB) to load the image.

Please find the thread below on the exact same topic.

http://scn.sap.com/thread/3242930

Regards,

Ravi

former_member212706
Participant
0 Kudos

Hi Ravindra,

Thanks a lot. Yes i should have mentioned BLOB.

Pardon my ignorance. I could not fully understand how the images could be loaded into HANA DB via JDBC driver. Could you please explain in detail.

Thanks,

Rajesh.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

If you want to upload using python you can use this:

#!/usr/bin/python

con = dbapi.connect(‘hanahost', 30015, 'SYSTEM', '********') #Open connection to SAP HANA

cur = con.cursor() #Open a cursor

file = open('doc.pdf', 'rb') #Open file in read-only and binary

content = file.read() #Save the content of the file in a variable

cur.execute("INSERT INTO BLOBTEST VALUES(?,?)", (2,content)) #Save the content to a table

file.close() #Close the file

cur.close() #Close the cursor

con.close() #Close the connection