美文网首页
pymysql多条件动态查询(含模糊查询)

pymysql多条件动态查询(含模糊查询)

作者: 寒冰助手 | 来源:发表于2021-01-14 17:24 被阅读0次
sql = 'select * from order_info  where (pay_time > "{0}" or "{0}"="None") and (pay_time < "{1}" or "{1}"="None") and (order_id like "%{2}%" or "{2}"="None") and (other_info like "%{3}%" or "{3}"="None") and (platform like "%{4}%" or "{4}"="None") and (tracking like "%{5}%" or "{5}"="None") and (operater = "{6}" or "{6}"="None")'.format(start_time, end_time, order_id, name, platform, tracking, operater)
mysql.execute(sql)
res = mysql.fetchall()

相关文章

网友评论

      本文标题:pymysql多条件动态查询(含模糊查询)

      本文链接:https://www.haomeiwen.com/subject/ajwvaktx.html