【发布时间】:2017-10-12 13:53:28
【问题描述】:
我很困惑如何在 Python 中编码。
以下代码可从 pgsql 命令行运行。
select * from consultation_tbl where consultation_status in ('S','C','R');
但是在 Python 中,我不知道如何编码。
chat_str = "\'S\',\'C\',\'R\'"
cursor.execute(" \
SELECT * FROM consultation_tbl
WHERE consultation_status IN ( %s )", [chat_str])
请给我一个建议。
【问题讨论】:
-
字符串替换可能导致 SQL 注入攻击。
标签: python sql postgresql python-3.x