Skip to content

Commit

Permalink
Update backfill scripts for classifications (#44)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yuenmichelle1 authored Oct 19, 2023
1 parent aac036a commit 21df140
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/save_classifications_chunk_in_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

with psycopg.connect(f"host={PANOPTES_CONN} port={PANOPTES_PORT} dbname={PANOPTES_DB} user={PANOPTES_USER} password={PANOPTES_PW} sslmode=require keepalives=1 keepalives_idle=30 keepalives_interval=10 keepalives_count=20") as panoptes_db_conn:
with open(f"prod_classifications_{offset}.csv", "wb") as f:
with panoptes_db_conn.cursor(name="panoptes_cursor").copy(f"COPY ({classifications_query}) TO STDOUT WITH CSV HEADER", (FIRST_INGESTED_CLASSIFICATION_ID,)) as panoptes_copy:
with panoptes_db_conn.cursor(name="panoptes_cursor").copy(f"COPY ({query}) TO STDOUT WITH CSV HEADER", (FIRST_INGESTED_CLASSIFICATION_ID,)) as panoptes_copy:
for data in panoptes_copy:
f.write(data)
offset+= 1
Expand Down

0 comments on commit 21df140

Please sign in to comment.