From 9fd64416067bbf98a451cf5b09521da9bffaa3f5 Mon Sep 17 00:00:00 2001 From: Gent Semaj Date: Wed, 24 Jan 2024 13:57:43 -0500 Subject: [PATCH] Fix for large packet size --- json2xdb/json2xdb.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/json2xdb/json2xdb.py b/json2xdb/json2xdb.py index adcc32e..b39e49b 100644 --- a/json2xdb/json2xdb.py +++ b/json2xdb/json2xdb.py @@ -141,19 +141,31 @@ def main(conn, xdt_path): process_xdt_table(cursor, root, table_name, mappings) conn.commit() +def connect_to_db(): + return mysql.connector.connect( + host="localhost", + user="root", + password="mypassword", + database="tabledata" + ) + +def prep_db(): + conn = connect_to_db() + cursor = conn.cursor() + cursor.execute("SET GLOBAL max_allowed_packet=1073741824") + conn.commit() + conn.close() + # %% if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python3 json2xdb.py ") sys.exit(1) xdt_path = sys.argv[1] - conn = mysql.connector.connect( - host="localhost", - user="root", - password="mypassword", - database="tabledata" - ) + prep_db() + conn = connect_to_db() main(conn, xdt_path) + conn.close() # %%