Python and MySQLdb: substitution of table resulting in syntax error

前端 未结 4 1243
日久生厌
日久生厌 2020-11-27 23:33

I need to dynamically change tables and variables from time to time, so I wrote a python method like this:

    selectQ =\"\"\"SELECT * FROM  %s WHERE %s = %s         


        
4条回答
  •  Happy的楠姐
    2020-11-28 00:03

    You'll have to use string substitution to add the table and column names, the driver will only handle parameters.

    Ed: NM, Daniel answered faster and more completely

提交回复
热议问题