Python SQL query string formatting

后端 未结 10 1514
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 08:51

I\'m trying to find the best way to format an sql query string. When I\'m debugging my application I\'d like to log to file all the sql query strings, and it is important t

10条回答
  •  鱼传尺愫
    2020-12-04 09:15

    you could put the field names into an array "fields", and then:

    
    sql = 'select %s from table where condition1=1 and condition2=2' % (
     ', '.join(fields))
    

提交回复
热议问题