rest-endpoint: init

This commit is contained in:
2025-12-22 19:59:31 +09:00
parent 00793bed2b
commit e719840f72
8 changed files with 2939 additions and 7 deletions

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p "python3.withPackages(ps: with ps; [ psycopg2-bin ])"
from argparse import ArgumentParser, Action
import os
from pathlib import Path
from datetime import datetime
from dataclasses import dataclass
import gzip
import os
from argparse import Action, ArgumentParser
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
import psycopg2
from psycopg2.extras import execute_values
@@ -85,7 +85,7 @@ def insert_sessions_into_db(
with conn:
with conn.cursor() as cur:
cur.execute("""
CREATE TABLE IF NOT EXISTS "minecraft_login_sessions"(
CREATE TABLE IF NOT EXISTS "minecraft_login_session"(
"username" TEXT NOT NULL,
"start" TIMESTAMP NOT NULL,
"duration" BIGINT NOT NULL CHECK (duration >= 0),
@@ -96,7 +96,7 @@ def insert_sessions_into_db(
execute_values(
cur,
"""
INSERT INTO minecraft_login_sessions(username, start, duration)
INSERT INTO minecraft_login_session(username, start, duration)
VALUES %s
ON CONFLICT DO NOTHING
""",