bring back the badge editor
This commit is contained in:
14
app/db.py
14
app/db.py
@@ -49,6 +49,12 @@ class DB:
|
||||
yield conn
|
||||
|
||||
|
||||
@staticmethod
|
||||
def binding_list(num: int) -> str:
|
||||
"""Returns a bindings list string for the given number of bindings."""
|
||||
return '(%s)' % ','.join('?' * num)
|
||||
|
||||
|
||||
def query(self, sql, *args):
|
||||
"""Executes a query and returns a list of dictionaries."""
|
||||
with self.connection() as conn:
|
||||
@@ -104,8 +110,12 @@ class DB:
|
||||
conditions = []
|
||||
params = []
|
||||
for col, op, val in self._where:
|
||||
conditions.append(f"{col} {op} ?")
|
||||
params.append(val)
|
||||
if isinstance(val, tuple) or isinstance(val, list):
|
||||
conditions.append(f"{col} {op} {db.binding_list(len(val))}")
|
||||
params.extend(val)
|
||||
else:
|
||||
conditions.append(f"{col} {op} ?")
|
||||
params.append(val)
|
||||
|
||||
return " WHERE " + " AND ".join(conditions), params
|
||||
|
||||
|
||||
Reference in New Issue
Block a user