diff --git a/code/main.py b/code/main.py
index 39fba55aee35ef0eb5af67ead6218ebcac2083f7..3561478d7bcddb41de3c6ec0394a1ab0d8a202d6 100644
--- a/code/main.py
+++ b/code/main.py
@@ -5,6 +5,7 @@ import threading
 import os
 import sys
 import duckdb
+import database_connection
 
 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'machine_learning_models')))
 base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -323,7 +324,11 @@ class PacketCaptureGUI:
         tree.heading("type_of_threat", text="Type of Threat")
 
         # Connect to the DuckDB database and fetch data
+
         conn = duckdb.connect('packets_data.duckdb')
+
+        database_connection.initiate_database(conn)
+        database_connection.commit(conn)
         query = "SELECT * FROM packets"
         result = conn.execute(query).fetchall()
 
@@ -331,6 +336,7 @@ class PacketCaptureGUI:
         for row in result:
             tree.insert("", tk.END, values=row)
 
+        database_connection.commit(conn)
         conn.close()
 
         data_window.protocol("WM_DELETE_WINDOW", lambda: self.on_close_window(data_window))
diff --git a/code/package_capture/src/database_connection.py b/code/package_capture/src/database_connection.py
index c233621b8dcc3009f0bc4dd4f819754d8cb81e8a..18af1bd7d64fafae77ef6590ad5948d6f2a52402 100644
--- a/code/package_capture/src/database_connection.py
+++ b/code/package_capture/src/database_connection.py
@@ -94,4 +94,7 @@ def extract_info(packet):
     destination_mac = packet[Ether].dst if Ether in packet else UNDEFINED
     source_port = packet[TCP].sport if TCP in packet else UNDEFINED
     destination_port = packet[TCP].dport if TCP in packet else UNDEFINED
-    return destination_ip, destination_mac, destination_port, source_ip, source_mac, source_port
\ No newline at end of file
+    return destination_ip, destination_mac, destination_port, source_ip, source_mac, source_port
+
+def commit(connection):
+    connection.commit()
\ No newline at end of file
diff --git a/code/package_capture/src/packet_capturing.py b/code/package_capture/src/packet_capturing.py
index 63b4762610a5379698072f52c66d77d7ca1b80f1..c117dc3acae001fdc6286bc94b1385065685f9bd 100644
--- a/code/package_capture/src/packet_capturing.py
+++ b/code/package_capture/src/packet_capturing.py
@@ -5,6 +5,7 @@ from scapy.all import sniff
 from scapy.packet import raw, Raw
 from collections import defaultdict
 import duckdb as duckdb
+
 import database_connection as db_conn
 import time
 
@@ -12,7 +13,7 @@ import sys
 sys.stdout.reconfigure(line_buffering=True)
 
 ## Database ##
-connection = duckdb.connect('../../packets_data.duckdb')
+connection = duckdb.connect('packets_data.duckdb')
 ##############
 
 ## Reserved IPs ##