dodano funkcje increment_stat

This commit is contained in:
kubab
2025-06-03 19:05:44 +02:00
parent 206f7d6fb3
commit cecc914935

View File

@@ -24,6 +24,13 @@ class baza():
self.db = self.initDB(self.app, config)
self.refresh_session()
def increment_stat(self, table: str, where: dict, column: str, value: int):
with self.Session() as session:
model = self.models[table]
session.query(model).filter_by(**where).update({column: getattr(model, column) + value})
session.commit()
def initDB(self, app, config):
global sportowcy, trofea, sportowcy_w_meczach, statystyki_sportowcow, kluby, mecze
tnp = config['general']['db_prefix'] + "_lewangoalski_"
@@ -368,4 +375,4 @@ class baza():
session.commit()
return 0
return 1
return 1