From 5f56a07af49abedf1f319ce26504f3505cabe3dc Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Thu, 21 Sep 2023 14:53:07 -0500 Subject: [PATCH] keeping env vars consistent with constants --- scripts/backfill_talk_comments.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/backfill_talk_comments.py b/scripts/backfill_talk_comments.py index 0bd4fe7..d5d04d8 100644 --- a/scripts/backfill_talk_comments.py +++ b/scripts/backfill_talk_comments.py @@ -1,7 +1,8 @@ import os import psycopg +from datetime import datetime -TALK_CONN = os.getenv('TALK_CONNECTION') +TALK_CONN = os.getenv('TALK_CONN') TALK_PORT = os.getenv('TALK_PORT') TALK_DB = os.getenv('TALK_DB') TALK_USER = os.getenv('TALK_USER') @@ -11,11 +12,18 @@ ERAS_DB = os.getenv('ERAS_DB') ERAS_USER = os.getenv('ERAS_USER') ERAS_PW = os.getenv('ERAS_PW') -FIRST_INGESTED_COMMENT_ID = os.getenv('FIRST_COMMENT_ID') +FIRST_INGESTED_COMMENT_ID = os.getenv('FIRST_INGESTED_COMMENT_ID') +now = datetime.now() +current_time = now.strftime("%H:%M:%S") +print("COMMENTS backfill BEFORE Time =", current_time) with psycopg.connect(f"host={TALK_CONN} port={TALK_PORT} dbname={TALK_DB} user={TALK_USER} password={TALK_PW} sslmode=require") as talk_db_conn, psycopg.connect(f"host={TIMESCALE_CONNECTION} port={TIMESCALE_PORT} dbname={ERAS_DB} user={ERAS_USER} password={ERAS_PW} sslmode=require") as timescale_db_conn: with talk_db_conn.cursor(name="talk").copy("COPY (SELECT id::bigint as comment_id, created_at as event_time, updated_at as comment_updated_at, project_id::bigint, user_id::bigint, created_at, updated_at from comments where id < %s) TO STDOUT (FORMAT BINARY)", (FIRST_INGESTED_COMMENT_ID,)) as talk_copy: with timescale_db_conn.cursor().copy("COPY comment_events FROM STDIN (FORMAT BINARY)") as timescale_copy: for data in talk_copy: - timescale_copy.write(data) \ No newline at end of file + timescale_copy.write(data) + + finish = datetime.now() + finish_time = finish.strftime("%H:%M:%S") + print("COMMENTS backfill AFTER Time =", finish_time) \ No newline at end of file