From 6678075ddaaf4ff8a1a384a1e6102b5402efe205 Mon Sep 17 00:00:00 2001 From: Greg Finley Date: Wed, 10 Apr 2024 21:40:22 -0700 Subject: [PATCH] Postgres dialect --- process_file/main.py | 4 ++-- queue_files/main.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/process_file/main.py b/process_file/main.py index 556fe54..abe6958 100644 --- a/process_file/main.py +++ b/process_file/main.py @@ -25,8 +25,8 @@ def run(event, context): ) query = """ INSERT INTO dropbox (desktop_path, filename, status) - VALUES (%s, SUBSTRING_INDEX(%s, '/', -1), 'done') - ON DUPLICATE KEY UPDATE status = 'done' + VALUES (%s, SPLIT_PART(%s, '/', -1), 'done') + ON CONFLICT (desktop_path) DO UPDATE SET status = 'done' """ with psycopg.connect(os.environ["NEON_DATABASE_URL"]) as conn: with conn.cursor() as cursor: diff --git a/queue_files/main.py b/queue_files/main.py index ee2db8b..bcb3ec6 100644 --- a/queue_files/main.py +++ b/queue_files/main.py @@ -58,7 +58,7 @@ def run(event, context): print(f"Queueing {clean_name}") query = """ INSERT INTO dropbox (desktop_path, filename, status) - VALUES (%s, SUBSTRING_INDEX(%s, '/', -1), 'pending') + VALUES (%s, SPLIT_PART(%s, '/', -1), 'pending') ON CONFLICT (desktop_path) DO NOTHING """ with conn.cursor() as cursor: