Skip to content
Advertisement

Python(Flask,JayDeBeApi) RuntimeError: No matching overloads found for prepareStatement

as mentioned in the title i get this error when i try to execute a prepared statement. The full error is:

RuntimeError: No matching overloads found for prepareStatement in find. at nativecommonjp_method.cpp:127

As far as i can understand is, that propably that since i am trying to use a prepared statement, that the compiler can not find something to overload the ? placeholder.

Code snippet:

 curs = self.dbconn.cursor()  
 sqlLogin = ("SELECT name,email FROM BENUTZER where name=? and email=?", ( benutzerObjekt.name,benutzerObjekt.email))
 curs.execute(sqlLogin)

The error seems to happen at curs.execute(sqlLogin), which is shown to me in the traceback when debugging.

I’m trying to use the input of an html input, which is stored in benutzerObjekt.name and benutzerObjekt.email as input for the select SQL statement. So most probably something is wrong with either my SQL statement, or the execution of the statement, which is underlined when debugging. I am using db2.

Thanks in advance!

Advertisement

Answer

You need to pass parameters as second argument in cursor.execute. Right now your query is a nested tuple of two items with first being a string and second item being a tuple of two values.

Consider separating the arguments for function call:

curs = self.dbconn.cursor() 

# SINGLE STRING VALUE
sqlLogin = "SELECT name,email FROM BENUTZER WHERE name=? AND email=?"

# TUPLE OF TWO VALUES
vals = (benutzerObjekt.name, benutzerObjekt.email)

# PASS SQL AND PARAMS SEPARATELY
curs.execute(sqlLogin, vals)

Alternatively, you can unpack your nested tuple using asterisk, *:

sqlLogin = (
    "SELECT name,email FROM BENUTZER where name=? and email=?", 
    (benutzerObjekt.name, benutzerObjekt.email)
)

curs.execute(*sqlLogin)
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement