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: