Skip to content

Commit

Permalink
use upsert for targetphot files
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Oct 25, 2024
1 parent 446074a commit 24f832a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions py/specprodDB/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,11 @@ def load_file(filepaths, tcls, hdu=1, row_filter=None, q3c=None, chunksize=50000
data_chunk = orm_objects[k*chunksize:(k+1)*chunksize]
if len(data_chunk) > 0:
loaded_rows += len(data_chunk)
dbSession.add_all(data_chunk)
if tn == 'photometry' and os.path.basename(filepath).startswith('targetphot'):
statement = upsert(data_chunk, do_nothing=True)
dbSession.execute(statement)
else:
dbSession.add_all(data_chunk)
dbSession.commit()
log.info("Inserted %d rows in %s.",
min((k+1)*chunksize, finalrows), tn)
Expand Down Expand Up @@ -1721,7 +1725,7 @@ def main():
'targetphot': [{'filepaths': target_files,
'tcls': Photometry,
'hdu': 'TARGETPHOT',
'row_filter': deduplicate_targetid,
# 'row_filter': deduplicate_targetid,
'q3c': 'ra',
'chunksize': chunksize
}],
Expand Down

0 comments on commit 24f832a

Please sign in to comment.