baztian / jaydebeapi

JayDeBeApi module allows you to connect from Python code to databases using Java JDBC. It provides a Python DB-API v2.0 to that database.
GNU Lesser General Public License v3.0
365 stars 148 forks source link

Insert Array types #156

Open ppatrickt opened 4 years ago

ppatrickt commented 4 years ago

Is it possible to insert ARRAY types? In particular String Arrays, e.g. ['foo','bar'] (<class 'list'>).

I tried to do an executemany() but received this error:

File "/usr/local/lib64/python3.6/site-packages/jaydebeapi/init.py", line 516, in executemany self._set_stmt_parms(self._prep, parameters) File "/usr/local/lib64/python3.6/site-packages/jaydebeapi/init.py", line 490, in _set_stmt_parms prep_stmt.setObject(i + 1, parameters[i]) RuntimeError: No matching overloads found for setObject in find. at native/common/jp_method.cpp:127

If I try <class 'jpype._jclass.java.util.ArrayList'>, I get this:

File "/usr/local/lib64/python3.6/site-packages/jaydebeapi/init.py", line 524, in executemany update_counts = self._prep.executeBatch() jpype._jexception.org.apache.phoenix.exception.BatchUpdateExecutionPyRaisable: org.apache.phoenix.exception.BatchUpdateExecution: ERROR 1106 (XCL06): Exception while executing batch.

baztian commented 4 years ago

This is currently not supported. We would need to call the setArray Method or create a java.sql.Array beforehand. https://docs.oracle.com/javase/tutorial/jdbc/basics/array.html#storing_array

But sounds interesting.

baztian commented 4 years ago

Related to #52