jaydebeapi executemany() method doesn't work using sql query containing only one parameter, but at the same time two parameters works fine.
For example given query doesn't executes:
cursor.executemany("DELETE FROM table1 WHERE col1 = ?", tup_df)
And this one works fine
cursor.executemany("DELETE FROM table1 WHERE col1 = ? AND col2 = ?", tup_df)
assuming that the expression going after AND
manipulates with an existing column in the db (using some workarounds like 1 = ?
or so didn't work out)
Test code using first case
df = pandas.DataFrame(data={'col1': [3563412]})
conn = jaydebeapi.connect(jar_class, url, {'user': user, 'password': password}, jar_path)
cursor = conn.cursor()
row_count = 0
for _, df in df.groupby(np.arange(len(df)) // 2000):
tup_df = [tuple(x) for x in df.values]
cursor.executemany("DELETE FROM table1 WHERE col1 = ?", tup_df)
row_count = row_count + cursor.rowcount
print(row_count + ' row(s) processed')
Test code for the second case
df = pandas.DataFrame(data={'col1': [3563412]})
conn = jaydebeapi.connect(jar_class, url, {'user': user, 'password': password}, jar_path)
cursor = conn.cursor()
row_count = 0
for _, df in df.groupby(np.arange(len(df)) // 2000):
tup_df = [tuple(x) for x in df.values]
cursor.executemany("DELETE FROM table1 WHERE col1 = ? AND col2 = ?", tup_df)
row_count = row_count + cursor.rowcount
print(row_count + ' row(s) processed')
Throwing error:
Traceback (most recent call last):
File "test.py", line 21, in <module>
cursor.executemany("DELETE FROM table1 WHERE col1 = ?", tup_df)
File "/home/ray/.local/lib/python3.6/site-packages/jaydebeapi/__init__.py", line 516, in executemany
self._set_stmt_parms(self._prep, parameters)
File "/home/ray/.local/lib/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
Current db is db2, jaydebeapi - 1.1.1, jpype - 0.6.3, python - 3.6. Changing DB didn't help. Any help will be much thankful.