sqlite支持为您解析参数:
$ cur.execute("select name from people where age=?;", (age,))
如何访问解析后的 sql?像这样的东西:
$ age = 18
$ cur.format("select name from people where age=?;", (age,))
"select name from people where age=18;"
最佳答案
你不能。没有可访问的结果 SQL,因为查询永远不会组装成单个字符串。 sqlite库分别接收sql字符串和参数。
关于python - 如何使用sqlite的参数解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9271322/