How do I escape % from python mysql query

后端 未结 1 963
感情败类
感情败类 2020-11-28 13:56

How do I escape the % from a mysql query in python.

For example

query = \"\"\"SELECT DATE_FORMAT(date_time,\'%Y-%m\') AS dd
FROM some_table
WHERE som         


        
相关标签:
1条回答
  • 2020-11-28 14:53

    Literal escaping is recommended by the docs:

    Note that any literal percent signs in the query string passed to execute() must be escaped, i.e. %%.

    0 讨论(0)
提交回复
热议问题