Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
将 python 与 sqlite DB 一起使用 - 用于转义数据并拉出数据的方法是什么?
使用 pysqlite2
谷歌有相互矛盾的建议。
使用第二个参数args传递参数;不要自己逃避。这不仅更容易,还有助于防止 SQL 注入攻击。
args
cursor.execute(sql,args)
例如,
cursor.execute('INSERT INTO foo VALUES (?, ?)', ("It's okay", "No escaping necessary") )