diff options
author | Dennis Eriksen <d@ennis.no> | 2023-02-04 20:23:14 +0100 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2023-02-04 20:23:21 +0100 |
commit | 3c9a54e0958e7c0341e470f508e5fbc6db920388 (patch) | |
tree | 3d9cb86bcb6454f6f615c5dc71388ac12c75c434 /scripts/nb.py | |
parent | adding variable to env.sample (diff) | |
download | energyscripts-3c9a54e0958e7c0341e470f508e5fbc6db920388.tar.gz |
sql-variables in common was stupid. put them where they are used
Diffstat (limited to 'scripts/nb.py')
-rw-r--r-- | scripts/nb.py | 14 |
1 files changed, 12 insertions, 2 deletions
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) |