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.
This commit is contained in:
parent
a0c50e0fb0
commit
67f9bb49c0
|
@ -0,0 +1,14 @@
|
||||||
|
#!/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()
|
Loading…
Reference in New Issue