Commit 0ee18e5a authored by Antonin Dvorak's avatar Antonin Dvorak
Browse files

sqlite3 - get rid of *args, use only optional argument

parent fbba87c1
...@@ -388,7 +388,7 @@ class BaseOutlierAnalyser(ABC): ...@@ -388,7 +388,7 @@ class BaseOutlierAnalyser(ABC):
query = '''INSERT OR IGNORE INTO scores query = '''INSERT OR IGNORE INTO scores
VALUES (?, ?, ?, ?, ?, ?)''', VALUES (?, ?, ?, ?, ?, ?)''',
upperbound = 10, upperbound = 10,
row) params = row)
conn_score.close() conn_score.close()
......
...@@ -250,7 +250,7 @@ def save_scores_local_sqlite(analyser, ...@@ -250,7 +250,7 @@ def save_scores_local_sqlite(analyser,
query = '''INSERT OR IGNORE INTO scores query = '''INSERT OR IGNORE INTO scores
VALUES (?, ?, ?, ?, ?, ?)''', VALUES (?, ?, ?, ?, ?, ?)''',
upperbound = 10, upperbound = 10,
row) params = row)
conn_score.close() conn_score.close()
...@@ -663,7 +663,7 @@ def analysis(module_name, class_name, alias_name, hyperparameters, ...@@ -663,7 +663,7 @@ def analysis(module_name, class_name, alias_name, hyperparameters,
query = '''INSERT INTO time query = '''INSERT INTO time
VALUES (?, ?, ?, ?, datetime('now', 'localtime'))''', VALUES (?, ?, ?, ?, datetime('now', 'localtime'))''',
upperbound = 10, upperbound = 10,
[data_dict_train["date_start"], params = [data_dict_train["date_start"],
data_dict_train["date_end_excluded"], data_dict_train["date_end_excluded"],
algo_name, algo_name,
training_time]) training_time])
......
...@@ -392,7 +392,7 @@ def score_benchmark(folder_scores, hostgroup, ...@@ -392,7 +392,7 @@ def score_benchmark(folder_scores, hostgroup,
query = '''INSERT OR IGNORE INTO auc query = '''INSERT OR IGNORE INTO auc
VALUES (?, ?, ?, ?, ?, ?)''', VALUES (?, ?, ?, ?, ?, ?)''',
upperbound = 10, upperbound = 10,
(hostgroup, algo_name, family, roc_auc, int(w), end_week)) params = (hostgroup, algo_name, family, roc_auc, int(w), end_week))
conn_score.close() conn_score.close()
# # CUMULATIVE QUANTITIES # # CUMULATIVE QUANTITIES
......
...@@ -4,7 +4,7 @@ import time ...@@ -4,7 +4,7 @@ import time
def modify_db(conn, def modify_db(conn,
query, query,
upperbound=10, upperbound=10,
*args): params = None):
"""Wrapper for modifications (INSERT, UPDATE, DELETE or REPLACE) of Sqlite3 database. """Wrapper for modifications (INSERT, UPDATE, DELETE or REPLACE) of Sqlite3 database.
Executes given query and commits it - in case of lock it retries the commit Executes given query and commits it - in case of lock it retries the commit
Params Params
...@@ -15,7 +15,7 @@ def modify_db(conn, ...@@ -15,7 +15,7 @@ def modify_db(conn,
query to run query to run
upperbound: int upperbound: int
number of retries to execute query / commit to db number of retries to execute query / commit to db
args: array params: array
additional arguments for execute query, optional additional arguments for execute query, optional
""" """
...@@ -23,8 +23,8 @@ def modify_db(conn, ...@@ -23,8 +23,8 @@ def modify_db(conn,
# retry db execute # retry db execute
for x in range(1, upperbound + 1): for x in range(1, upperbound + 1):
try: try:
if args: if params:
c.execute(query, *args) c.execute(query, params)
else: else:
c.execute(query) c.execute(query)
except Exception as e: except Exception as e:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment