diff options
author | dennis <d@ennis.no> | 2023-01-31 21:13:35 +0100 |
---|---|---|
committer | dennis <d@ennis.no> | 2023-01-31 21:13:35 +0100 |
commit | 9cb0e8739b00337dc70aa3a0909f4880f2d5b5e1 (patch) | |
tree | 077e9f0d6fc3ab236cb2d86f20416e7ef8550571 /neohub2pgsql.py | |
parent | added queue, in case db-connection is down (diff) | |
download | energyscripts-9cb0e8739b00337dc70aa3a0909f4880f2d5b5e1.tar.gz |
use new db thingy
Diffstat (limited to 'neohub2pgsql.py')
-rwxr-xr-x | neohub2pgsql.py | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/neohub2pgsql.py b/neohub2pgsql.py index 0c760e5..646fa60 100755 --- a/neohub2pgsql.py +++ b/neohub2pgsql.py @@ -4,15 +4,10 @@ import os import asyncio import neohubapi.neohub as neohub -import psycopg2 +from todb import todb neohub_ip = os.environ['el_neohub_ip'] neohub_port = os.environ['el_neohub_port'] -pg_db = os.environ['el_pg_db'] -pg_host = os.environ['el_pg_host'] -pg_user = os.environ['el_pg_user'] -pg_pass = os.environ['el_pg_pass'] -pg_table = "neohub" values = [] @@ -29,12 +24,4 @@ async def run(): asyncio.run(run()) -conn = psycopg2.connect(database=pg_db, host=pg_host, user=pg_user, password=pg_pass) -cur = conn.cursor() - -try: - cur.executemany("INSERT INTO " + pg_table + " (time, device_id, away, heat_mode, heat_on, current_floor_temperature, target_temperature, temperature) VALUES(%s,%s,%s,%s,%s,%s,%s,%s)", values) - conn.commit() -except Exception as e: - conn.rollback() - raise e +todb("INSERT INTO neohub (time, device_id, away, heat_mode, heat_on, current_floor_temperature, target_temperature, temperature) VALUES(%s,%s,%s,%s,%s,%s,%s,%s)", values) |