config test

This commit is contained in:
David 2023-01-04 13:38:32 +01:00
parent f82ec7a80e
commit 4c3f8a8eef

View File

@ -82,14 +82,12 @@ class Stats:
return octets,unit return octets,unit
def parse(self): def parse(self):
res = None tot_part_start = tot_part_end = 0
while res is None: res = self.db.dbQuery(f"""SELECT value_field FROM {dbName} WHERE timestamp = {self.startDate} AND key_field = 'total_participants' ORDER by id""")
res = self.db.dbQuery(f"""SELECT * FROM {dbName} WHERE timestamp > {self.startDate} AND timestamp < {self.endDate} ORDER by id""") print(res)
if res is None: res = self.db.dbQuery(f"""SELECT value_field FROM {dbName} WHERE timestamp = {self.endDate} AND key_field = 'total_participants' ORDER by id""")
time.sleep(60) print(res)
#if res is None: res = self.db.dbQuery(f"""SELECT * FROM {dbName} WHERE timestamp > {self.startDate} AND timestamp < {self.endDate} ORDER by id""")
# sys.exit('Traitement en cours, base de données indisponible')
consolided = {} consolided = {}
moy_conf_by_day = 0 moy_conf_by_day = 0
for line in res: for line in res:
@ -158,13 +156,17 @@ class SQLite:
self.conn.close() self.conn.close()
def dbQuery(self,query='SELECT'): def dbQuery(self,query='SELECT'):
try: rows = None
self.__openDb() while rows is None:
self.cursor.execute(query) try:
rows = self.cursor.fetchall() self.__openDb()
self.__closeDb() self.cursor.execute(query)
except sqlite3.OperationalError: rows = self.cursor.fetchall()
rows = None self.__closeDb()
except sqlite3.OperationalError:
rows = None
time.sleep(30)
return rows return rows
def dbInsert(self,ts,k,v): def dbInsert(self,ts,k,v):