cancel
Showing results for 
Search instead for 
Did you mean: 

hdbcli cursor usage with Multiprocessing in Python

ailang
Explorer
0 Kudos

I'm using the hdbcli to connect to the HANA DB and was able to get the result set, but I can't seem to use the result set directly in the enumeration in Python, rather I have to run the result set via the loop and then use each row.

This means I have to use an additional loop for post-HANA read and write operations.

If I do use it I'm getting the error "cannot pickle 'pyhdbcli.ResultRow' object", let me know if you have any inputs.

Vitaliy-R
Developer Advocate
Developer Advocate
0 Kudos

Could you please share the code you are using to make sure others get the complete picture?

Is it what you are looking for, or something else?

cursor = conn.cursor()
sql_command = "select * from M_TABLES"
cursor.execute(sql_command)
rows = cursor.fetchall()
for row in rows:
    print(row)
cursor.close()

Accepted Solutions (1)

Accepted Solutions (1)

Vitaliy-R
Developer Advocate
Developer Advocate
0 Kudos

Could you try

resultset =pool.apply_async( function_name, row.column_values for row in rows)

?

`row.column_values` should give you a tuple of values from the row, instead of an object of `pyhdbcli.ResultRow` data type.

ailang
Explorer

Thank you Witalij, I was able to move forward.

Answers (1)

Answers (1)

ailang
Explorer
0 Kudos

Thank you vitaliy.rudnytskiy for your response.

This is the code I'm currently using, as you can see we'll have to loop through each record to process it.

If I use the same code with Python enumeration like below throws the cannot pickle 'pyhdbcli.ResultRow' object

resultset = pool.apply_async( function_name, row for row in rows )