diff --git a/server/trackdirect/collector/PacketBatchInserter.py b/server/trackdirect/collector/PacketBatchInserter.py
index 1cbc85307c84f4957e92a9c17fc986873da85ad1..199b3ca86c0e1e06830b10a4f4695fe2550540c2 100644
--- a/server/trackdirect/collector/PacketBatchInserter.py
+++ b/server/trackdirect/collector/PacketBatchInserter.py
@@ -176,12 +176,11 @@ class PacketBatchInserter():
                                      packet.rawPath,
                                      packet.raw))
 
-        sql = ""
         try:
             # insert into packetYYYYMMDD
-            argString = ','.join(cur.mogrify(
+            argString = b','.join(cur.mogrify(
                 "(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", x) for x in datePacketTuples)
-            sql = "insert into " + packetTable + "(station_id, sender_id, map_id, source_id, packet_type_id, latitude, longitude, posambiguity, symbol, symbol_table, map_sector, related_map_sectors, marker_id, marker_counter, speed, course, altitude, rng, phg, latest_phg_timestamp, latest_rng_timestamp, timestamp, packet_tail_timestamp, is_moving, reported_timestamp, position_timestamp, comment, raw_path, raw) values " + argString + " RETURNING id"
+            sql = "insert into " + packetTable + "(station_id, sender_id, map_id, source_id, packet_type_id, latitude, longitude, posambiguity, symbol, symbol_table, map_sector, related_map_sectors, marker_id, marker_counter, speed, course, altitude, rng, phg, latest_phg_timestamp, latest_rng_timestamp, timestamp, packet_tail_timestamp, is_moving, reported_timestamp, position_timestamp, comment, raw_path, raw) values " + argString.decode() + " RETURNING id"
             cur.execute(sql)
         except psycopg2.InterfaceError as e:
             # Connection to database is lost, better just exit