我的问题是:
result = connection.execute(
"select id_number from Table where string like '_stringStart%' limit 1;")
给出错误:
query = query % escaped_args
TypeError: not enough arguments for format string
一个快速的谷歌说使用%%而不是%,但这也不起作用。我如何转义%,或者是否有其他方法可以查询以随机字母开头的字符串,而不是以某个序列开头?
发布于 2012-06-13 06:14:01
因为这是一个文字字符串,所以最好在这里使用绑定参数(使用text()
进行说明):
from sqlalchemy import text
connection.execute(
text("select * from table where "
"string like :string limit 1"),
string="_stringStart%")
https://stackoverflow.com/questions/10935854
复制相似问题