2

I am using pyodbc, impala driver for kudu on cloudera 5.16, Python 3.6.10 to do an upsert into kudu table. Insert works fine but upsert fails. I am getting an error: SQL contains 0 parameter markers, but 3 parameters were supplied', 'HY000' . The code looks like below:

import pyodbc
conn = pyodbc.connect('DSN=my-impala-dsn',autocommit=True) 
crsr = conn.cursor() 

crsr.execute("UPSERT INTO mydb.mytable (col1,col2,col3) values(?,?,?)", val1,val2,val3)

Any thoughts on the error?

ebeb
  • 429
  • 3
  • 12
  • 1
    Is impala version is more than 2.8? Is primary key defined properly on the table? – Koushik Roy Oct 04 '20 at 12:07
  • impalad version 2.12.0-cdh5.16.1, yes primary key is fine. Kudu table cannot be created without proper primary keys. Also if I run using DBeaver SQL editor the upsert works fine. Looks like Pyodbc has some limitations in upsert. – ebeb Oct 05 '20 at 16:50
  • Hmm, that's good to know. I think the way you passing arguments is incorrect. Can you try passing it in an array? Like `update t values (?,?,?), [V1,v2,v3])` – Koushik Roy Oct 06 '20 at 03:59
  • @ebeb, how did you solve your problem? – deeplay May 12 '22 at 10:13
  • 1
    I think I just went with delete the row and insert new row instead of upsert as far as I remember. – ebeb May 13 '22 at 11:04

0 Answers0