我有一个类似的问题,这个问题是用Python pysqlite not accepting my qmark parameterization回答的。
我的问题是:我想要参数化的字符串搜索,而不是字符串本身。
这是我的发言:
command = "select id, l from testDT where l like '%, ?]'"
cur.command(command, (123,))pysqlite返回以下错误:
pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.我确实理解这是因为qmark被解释为文字。但是,我不知道如何指定这样的“类似”搜索,而不把这些标记解释为文字。
以下搜索成功:
command = "select id, l from testDT where l like '%, {x}]' "
command = command.format(x=123)
cur.execute(command)但是,据我所知,这正是不应该使用format()函数的方式。
发布于 2014-03-07 11:50:16
以整批为参数,如:
command = "select id, l from testDT where l like ? "
cur.command(command, ('%, 123]',))https://stackoverflow.com/questions/22249267
复制相似问题