cancel
Showing results for 
Search instead for 
Did you mean: 

Upload pdf files via python (-10901, 'No space left in request packet')

Former Member
0 Kudos

Hello, I have tryed upload pdf files to hana db using python script. For upload I used follow tutorial http://saphanatutorial.com/implement-sap-hana-text-analysis-in-10-minutes/. I uploaded only one file with size less 1.6MB , and when I tryed uploaded pdf file more than 1.6 MB, I got follow error (-10901, 'No space left in request packet'). Perhaps my query too long, and therefore I got this error. I found, that this problem solving by change the parametr CommandBufferSize, but i don't think, that's a good idea. Anybody can show me another way by solve this problem? Just in case my python script:

from hdbcli import dbapi
def Upload():
    conn = dbapi.connect('ip', port, 'user', 'password')
    print (conn.isconnected())
	file = open('TestFile.pdf', 'rb') 
	content = file.read() 
    cursor = conn.cursor()
    cursor.execute("insert into SAPABAP1.ZATTACHTEST values(?,?)",('MyID',content)) 
	file.close() 
	conn.close()
	cursor.close()

Best Regards,
Ivan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Well, I solved my problem. First of all worth to saying than Hana Database has got small buffer size, and if we send file
inside sql statement, our buffer becomes overflow.

Eventualy I've created OdataService with this tutorial Uploading Files to SAP GW, Downloading Files from SAP GW – New Technique. And then you'll able to send files via python use requests

There's sample code, I hope that it'll be useful:

def SimplePost():
        url = 'odata https url'
        auth_q = 'user', 'password'
        headers_fetch = {'X-CSRF-Token': 'Fetch'}
        client = requests.session()
        client.get(url,auth=auth_q, verify=False, headers=headers_fetch)
        token=(client.get(url,auth=auth_q, verify=False, headers=headers_fetch).headers.get('x-csrf-token'))
        payload = {
            'x-csrf-token': token,
            'Content-type': 'application/pdf',
        }
        r=client.post(url,data=fileUpload, headers=payload,verify=False,)

Answers (0)