if action == 'list': condition = ['1=1'] if 'username' in webi and webi['username'] != '': condition.append("t.username = '{0}'".format(webi['username'])) if 'nickname' in webi and webi['nickname'] != '': condition.append("t.nickname like '%{0}%'".format(webi['nickname'])) if 'time' in webi and webi['time'] != '': condition.append("t.create_time like '{0}%'".format(webi['time'])) if 'locked' in webi and webi['locked'] != 'null' and webi['locked'] != '': condition.append("t.locked = '{0}'".format(webi['locked'])) params = tablehandle.get(webi) sql = """ select count(*) as c from sys_user t where {0} """.format(' and '.join(condition))
python sql语句where条件小技巧
最新推荐文章于 2024-06-04 21:13:34 发布