From df098acfabd67cf47823ed769c01f3afc0c3d909 Mon Sep 17 00:00:00 2001
From: Eunhak Lee <lee@enak.kr>
Date: Wed, 4 Dec 2024 17:55:35 +0900
Subject: [PATCH] =?UTF-8?q?feat:=20transaction=20=ED=85=8C=EC=9D=B4?=
 =?UTF-8?q?=EB=B8=94=EB=8F=84=20=EC=B1=84=EC=9B=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 push_to_db.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/push_to_db.py b/push_to_db.py
index 81c3e73..fbc3cd6 100644
--- a/push_to_db.py
+++ b/push_to_db.py
@@ -107,6 +107,11 @@ def match_part_obj_into_db(_part, part_type):
     return _matched_id
 
 
+def finalize_transaction(_cursor, _transaction_id, _user_id, _combination_id):
+    _cursor.execute("INSERT INTO transactions (id, user_id, combination_id) VALUES (%s, %s, %s);", _transaction_id, _user_id, _combination_id)
+    _cursor.fetchall()
+
+
 def func():
     value = R.lpop("mypc:queue")
     if value is None:
@@ -179,6 +184,13 @@ def func():
     print("Committing to DB")
     db_conn.commit()
 
+    print("Finalizing transaction")
+    with db_conn.cursor() as cursor:
+        finalize_transaction(cursor, _transaction_id, _user_id, _combination_id)
+
+    print("Committing to DB")
+    db_conn.commit()
+
     print("Removing anchor key from Redis")
     R.delete(f"mypc:code:{code}:document")
 
-- 
GitLab