Reputation: 592
Forgive my ignorance as I am new to oursql. I'm simply trying to pass a parameter to a statement:
cursor.execute("select blah from blah_table where blah_field = ?", blah_variable)
this treated whatever is inside the blah_variable as a char array so if I pass "hello" it will throw a ProgrammingError telling me that 1 parameter was expected but 5 was given.
I've tried looking through the docs but their examples are not using variables. Thanks!
Upvotes: 0
Views: 234
Reputation: 917
The cursor.execute()
call expects a params
argument that is iterable. The documentation only hints at it, but the code actually unpacks the argument and passes it to another function:
# from oursqlx/cursor.pyx:121
# in Cursor.execute()
else:
stmt.execute(*params)
You would need to phrase your call like:
cursor.execute("select blah from blah_table where blah_field = ?", [blah_variable]) # brackets!
Upvotes: 1