Manuel Taber Manuel Taber - 1 year ago 158
Python Question

Python fdb prepared statement list

Is it possible to add a list as prepared statement parameter in the fdb library in Python?


cur = con.cursor()
list = [1,2,3]
cur.execute("""SELECT * FROM data d WHERE d.field IN ?""", (list,))


"Error while preparing SQL statement:")\nDatabaseError: (\'Error while preparing SQL statement:\\n- SQLCODE: -104\\n- Dynamic SQL Error\\n- SQL error code = -104\\n- Token unknown - line 4, column 33\\n- ?\', -104, 335544569)\n'

Are there any known solutions?
Thanks in advance

Answer Source

Lists can't be used as a value to a parametrized query, you need to construct it yourself, by dynamically creating a query with either sufficient placeholders for all your list items, or with the literal values from your list.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download