bring back the badge editor

This commit is contained in:
2026-06-05 07:19:53 +03:00
parent c7ba23ad22
commit 6fab93ebeb
10 changed files with 426 additions and 12 deletions

View File

@@ -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