diff --git a/src/ecritureBDD.py b/src/ecritureBDD.py index 75c14fb..01232d3 100644 --- a/src/ecritureBDD.py +++ b/src/ecritureBDD.py @@ -1,9 +1,29 @@ import psycopg2 as psy import pandas as pd import getpass +import regles -def verifRegle(a): +def verifRegle(co): + cur=co.cursor() + cur.execute('''SELECT type,addresse,valeur FROM Status ORDER BY type,addresse;''') + res=cur.fetchall() + dataState={} + for row in res: + dataState[(row[0],int(row[1]))]=int(row[2]) + listRules=regles.getRegles() + for rule in listRules: + ruleWarning=0 + condition=len(rule[0]) + for i in rule[0]: + if dataState[(i[0],i[1])]==i[2]: + ruleAccepted+=1 + if ruleWarning>=condition: + if dataState(rule[1][0],rule[1][1])==rule[1][2]: + return False return True + + + def ecritureBDD(lStatus,connec): co = None @@ -21,4 +41,4 @@ def ecritureBDD(lStatus,connec): print(error) finally: if co is not None: - co.close() + co.close() \ No newline at end of file