0

Python pysqlite not accept 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 がリテラルとして解釈されるためであることは理解しています。ただし、qmarks がリテラルとして解釈されずに、qmarks を使用してそのような「like」検索を指定する方法がわかりません。

次の検索は成功します。

command = "select id, l from testDT where l like '%, {x}]' "
command = command.format(x=123)
cur.execute(command)

しかし、私が理解している限り、それはまさにformat() 関数を使用すべきではない方法です。

4

1 に答える 1