From 3c9a54e0958e7c0341e470f508e5fbc6db920388 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Sat, 4 Feb 2023 20:23:14 +0100 Subject: sql-variables in common was stupid. put them where they are used --- scripts/nb.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'scripts/nb.py') diff --git a/scripts/nb.py b/scripts/nb.py index 793b8a5..88d40c5 100644 --- a/scripts/nb.py +++ b/scripts/nb.py @@ -51,7 +51,17 @@ with open(temp.name, encoding="utf-8") as csvfile: csvReader = csv.DictReader(csvfile, delimiter=';') for item in csvReader: - values.append((item["TIME_PERIOD"],item["BASE_CUR"],item["QUOTE_CUR"],item["OBS_VALUE"])) + values.append(( + item["TIME_PERIOD"], + item["BASE_CUR"], + item["QUOTE_CUR"], + item["OBS_VALUE"])) + temp.close() -common.dbi(common.sql[common.name], values, verbose=True) +# SQL +sql = """ INSERT INTO nbex + VALUES(%s, %s, %s, %s) + ON CONFLICT (startdate,base_cur,quote_cur) DO NOTHING""" + +common.dbi(sql, values, verbose=True) -- cgit v1.2.3