[英]Python's sqlite3 module: get query with escaped parameters
The sqlite3 module allows one to use parameter substitution for queries like so: sqlite3模块允许对查询使用参数替换,如下所示:
import sqlite3
con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.execute("create table lang (name, first_appeared)")
cur.execute("insert into lang values (?, ?)", ("C", 1972))
I'd like to be able to get the "post-substitution" query string.我希望能够获得“替换后”查询字符串。 In the example above that would be:
在上面的示例中,这将是:
"insert into lang values ('C', '1972')"
Can it be done?可以做到吗? There doesn't seem to be a documented means of doing this, but I'd settle for undocumented.
似乎没有记录在案的方法可以做到这一点,但我愿意接受无证记录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.