mclog2psql: fix bugs

This commit is contained in:
2025-08-22 18:13:50 +02:00
parent c502758bcf
commit f56ff498db

View File

@@ -83,11 +83,12 @@ def insert_sessions_into_db(
with conn:
with conn.cursor() as cur:
cur.execute("""
CREATE TABLE IF NOT EXISTS minecraft_login_sessions(
username TEXT NOT NULL,
start TIMESTAMP WITH TIME ZONE NOT NULL,
duration INTEGER NOT NULL,
PRIMARY KEY (username, start)
CREATE TABLE IF NOT EXISTS "minecraft_login_sessions"(
"username" TEXT NOT NULL,
"start" TIMESTAMP NOT NULL,
"duration" INTEGER NOT NULL,
PRIMARY KEY ("username", "start")
)
""")
execute_values(
@@ -98,7 +99,7 @@ def insert_sessions_into_db(
page_size=1000,
)
except psycopg2.Error as e:
print(f"psycopg2 rrror: {e}")
print(f"psycopg2 error: {e}")
finally:
if conn is not None:
conn.close()
@@ -186,6 +187,7 @@ if __name__ == "__main__":
event_log = []
files = list(args.dir.glob("*.log.gz"))
files.sort()
for file in files:
print(f"Processing file: {file}")
event_log += parse_login_logout_events_from_file(file)