【发布时间】:2021-08-25 03:35:35
【问题描述】:
使用 Python 中的 sqlite3 模块。有没有办法将函数参数传递给 SQL 语句?大致类似于下面的示例代码:
def func(param):
cur.execute("""
SELECT * FROM this_table
WHERE this_column_value = param
""")
【问题讨论】:
-
cur.execute(""" SELECT * FROM this_table WHERE this_column_value = (?) """, param) -
@Epsi95 谢谢,您的代码在将
param更改为(param,)后运行良好,但我不能接受评论作为答案 -
您可以自己回答并接受以结束问题。