import sys

class ApikeyRecord:
    def __init__(self, key, neme, role):
        self.key = key
        self.name = name
        self.role = role

f = open(sys.argv[1], mode="r")

dump_file = open(sys.argv[2], mode="w")

rows = f.read().split("\n")

dump_file.write("""
CREATE TABLE evi.apikey
(
    key text COLLATE pg_catalog."default" NOT NULL,
    name text COLLATE pg_catalog."default" NOT NULL,
    role text COLLATE pg_catalog."default" NOT NULL
);
\n""")

for row in rows:
    if len(row) == 0:
        continue

    cols = row.split(",")
    record = ApikeyRecord(cols[0], cols[1], cols[2])

    dump_file.write(f"""INSERT INTO evi.apikey (key, neme, role)
                    VALUES ('{record.key}', '{record.name}');\n""")
