mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-24 01:04:09 +00:00
26 lines
603 B
Python
26 lines
603 B
Python
import logging
|
|
from src.database import db_cursor, db_connection
|
|
|
|
logger = logging.getLogger("rcgcdb.queue_handler")
|
|
|
|
|
|
class UpdateDB:
|
|
def __init__(self):
|
|
self.updated = []
|
|
|
|
def add(self, wiki, rc_id, feeds=None):
|
|
self.updated.append((wiki, rc_id, feeds))
|
|
|
|
def clear_list(self):
|
|
self.updated.clear()
|
|
|
|
def update_db(self):
|
|
for update in self.updated:
|
|
update_type = "postid" if update[2] is not None else "rcid"
|
|
db_cursor.execute("UPDATE rcgcdw SET {} = ? WHERE wiki = ?".format(update_type), (update[1],update[0],))
|
|
db_connection.commit()
|
|
self.clear_list()
|
|
|
|
|
|
DBHandler = UpdateDB()
|