Skip to content

Commit

Permalink
add log on copying over to target db so we can keep track of what fil…
Browse files Browse the repository at this point in the history
…es have been copied over. (#45)

* update classifications backfill script to chunk and save in file

* update to <= remove unused limit in query

* update copy into source

* split backfill to file creation then copy from files

* cast to int

* revert accidental adding commas on limit

* add keepalives to hopefully ensure connection does not get lost

* remove order by desc

* update to use the correct query

* add log to keep track of which files have finished being copied over
  • Loading branch information
yuenmichelle1 authored Oct 19, 2023
1 parent 21df140 commit 3700e8f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions scripts/copy_classifications_from_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
with psycopg.connect(f"host={TIMESCALE_CONNECTION} port={TIMESCALE_PORT} dbname={ERAS_DB} user={ERAS_USER} password={ERAS_PW} sslmode=require keepalives=1 keepalives_idle=30 keepalives_interval=10 keepalives_count=20") as timescale_db_conn:
with timescale_db_conn.cursor(name="timescale_cursor").copy("COPY classification_events FROM STDIN DELIMITER ',' CSV HEADER") as timescale_copy:
timescale_copy.write(open(f"prod_classifications_{output_file_no}.csv").read())
print("FINISHED COPYING FILE #", output_file_no)
output_file_no += 1

finish_time = datetime.now()
Expand Down

0 comments on commit 3700e8f

Please sign in to comment.