- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
def sql_select_filter(sql, flt, order=None, limit=None, offset=None, group_by=None, lock=None, withSelectWrapper=True):
if withSelectWrapper and group_by is None:
if re.search(r'^\s*select\s+', sql, flags=re.IGNORECASE | re.MULTILINE):
sql = "SELECT * FROM ( " + sql + " ) as z99 "
else:
sql = "SELECT * FROM " + sql + " "
sql = sql.replace("%", '%%')
where, vals = _make_where_conditions(flt)
if where is not None:
sql += " WHERE " + where
if group_by is not None and len(group_by):
sql += " GROUP BY " + ",".join(group_by)
if order is not None and len(order):
order_fields = []
for field, direction in order.items():
order_fields.append(field + " " + direction)
sql += " ORDER BY " + ",".join(order_fields)
if limit is not None:
sql += " LIMIT %s"
vals.append(limit)
if offset is not None:
sql += " OFFSET %s"
vals.append(offset)
if lock is not None:
sql += " FOR " + lock
return sql, vals
Olezhek28 20.05.2018 16:24 # +1
guest8 20.05.2018 23:57 # −999
lal3 20.05.2018 22:24 # 0
guest8 20.05.2018 23:55 # −999
roskomgovno 21.05.2018 04:40 # 0
syoma 21.05.2018 18:45 # 0
lal3 21.05.2018 19:02 # 0
guest8 21.05.2018 20:22 # −999
syoma 21.05.2018 20:27 # 0
guest8 21.05.2018 20:29 # −999
hellow 21.05.2018 23:15 # 0
guest8 20.05.2018 23:38 # −999
guest8 20.05.2018 23:40 # −999
guest8 21.05.2018 00:05 # −999
guest8 21.05.2018 00:15 # −999
guest8 21.05.2018 01:00 # −999
AnalStressTester 21.05.2018 19:40 # −1
Steve_Brown 23.05.2018 09:51 # −1
666_N33D135 23.05.2018 12:07 # −1