Skip to content

Commit

Permalink
@mbridak add_callhistory_item
Browse files Browse the repository at this point in the history
mbridak committed Oct 30, 2024
1 parent 82ee6f9 commit 5ce4422
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions not1mm/lib/database.py
Original file line number Diff line number Diff line change
@@ -387,6 +387,28 @@ def fetch_contest_by_id(self, contest_nr: str) -> dict:
logger.debug("%s", exception)
return {}

def add_callhistory_item(self, history: dict) -> None:
"""Add an item to the call history db"""
pre = "INSERT INTO CALLHISTORY("
values = []
columns = ""
placeholders = ""
for key in history.keys():
columns += f"{key},"
values.append(history[key])
placeholders += "?,"
post = f") VALUES({placeholders[:-1]});"
sql = f"{pre}{columns[:-1]}{post}"

try:
with sqlite3.connect(self.database) as conn:
logger.info("%s", sql)
cur = conn.cursor()
cur.execute(sql, tuple(values))
conn.commit()
except sqlite3.Error as exception:
logger.info("%s", exception)

def add_contest(self, contest: dict) -> None:
"""Add Contest"""

0 comments on commit 5ce4422

Please sign in to comment.