From 58e79255325053633fcb94459bc1310d680970d7 Mon Sep 17 00:00:00 2001 From: conache Date: Wed, 26 Jun 2024 18:29:29 +0300 Subject: [PATCH] Fix data-provider initialization on token timestamp conflicts --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 24917d1..f8da116 100644 --- a/app.py +++ b/app.py @@ -127,7 +127,7 @@ def init_price_token(token_name, token_from, token_to): for data_point in historical_data: timestamp = int(data_point[0] / 1000) # Convert milliseconds to seconds price = data_point[1] - cursor.execute("INSERT INTO prices (timestamp, token, price) VALUES (?, ?, ?)", (timestamp, token_name.lower(), price)) + cursor.execute("INSERT OR REPLACE INTO prices (timestamp, token, price) VALUES (?, ?, ?)", (timestamp, token_name.lower(), price)) print(f"inserting data point {timestamp} : {price}" ) conn.commit() conn.close()