Skip to content

Commit 5abd68f

Browse files
committed
psycopg handling
1 parent c935467 commit 5abd68f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

metrics_utility/library/collectors/controller/main_jobevent_service.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ def main_jobevent_service(*, db=None, since=None, until=None, output_dir=None):
5252
job_ids_set = set(job_id for job_id, _ in jobs)
5353

5454
# Use execute_values for efficient bulk insert
55-
try:
55+
# Check for psycopg2 vs psycopg3 using the same method as copy_table
56+
if hasattr(cursor, 'copy_expert') and callable(cursor.copy_expert):
57+
# psycopg2 (Automation Controller 4.4 and below)
5658
from psycopg2.extras import execute_values
5759

5860
execute_values(cursor, 'INSERT INTO temp_jobevent_service_jobs (job_id) VALUES %s', [(jid,) for jid in job_ids_set], page_size=1000)
59-
except ImportError:
60-
# Fallback for psycopg3
61+
else:
62+
# psycopg3 (Automation Controller 4.5 and above)
6163
for job_id in job_ids_set:
6264
cursor.execute('INSERT INTO temp_jobevent_service_jobs (job_id) VALUES (%s)', (job_id,))
6365

0 commit comments

Comments
 (0)