1
0
minecraft-tweaks-2a03/scripts/migrate_players.py
Ryan Fox 67f9bb49c0
Add script to migrate player data to SQLite
Requires the json and sqlite3 modules. I think these are installed by
default, but don't quote me on that.
2020-10-25 15:59:45 +00:00

15 lines
410 B
Python
Executable File

#!/usr/bin/env python3
import json
import sqlite3
with open("2a03.json", "r") as f:
config = json.loads(f.read())
sql = "INSERT INTO players (uuid, home) VALUES "
def sql_values(player):
return "('"+player["uuid"]+"', '"+json.dumps(player["home"])+"')"
sql += ", ".join(list(map(sql_values, config["members"])))
sql += ";"
conn = sqlite3.connect("2a03.db")
conn.execute(sql)
conn.commit()
conn.close()