better printing for alias migration script

This commit is contained in:
jesopo 2019-11-20 11:57:38 +00:00
parent dd3d72d8d3
commit 8eb26a5bd2

View file

@ -14,12 +14,15 @@ cursor.execute(
"""SELECT server_id, value FROM server_settings
WHERE setting='command-aliases'""")
results = cursor.fetchall()
print(results)
cursor.execute("SELECT server_id, alias FROM servers")
servers = dict(cursor.fetchall())
for server_id, value in results:
aliases = json.loads(value)
for alias, command in aliases.items():
print(server_id, alias, command)
print("[%s] Migrating '%s' ('%s')" %
(servers[server_id], alias, command))
cursor.execute("INSERT INTO server_settings VALUES (?, ?, ?)",
[server_id, "alias-%s" % alias, json.dumps(command)])
database.commit()