Add hashbang, script description, and useful error message to convert_db script
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
8
convert_db.py
Normal file → Executable file
8
convert_db.py
Normal file → Executable file
@@ -1,3 +1,7 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Convert between the old database format and the new one.
|
||||||
|
# You probably won't need to run this script.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
@@ -52,6 +56,10 @@ bans = old_db.execute("SELECT * FROM BANS").fetchall()
|
|||||||
print("Converting", len(bans), "rows")
|
print("Converting", len(bans), "rows")
|
||||||
|
|
||||||
for ban in bans:
|
for ban in bans:
|
||||||
|
if 'post' not in ban:
|
||||||
|
print("ERROR: The database either does not exist, or already exists in the new format. Exiting")
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
post = json.loads(ban["post"])
|
post = json.loads(ban["post"])
|
||||||
post["action"] = ban["action"]
|
post["action"] = ban["action"]
|
||||||
# post['board'] = ban['board']
|
# post['board'] = ban['board']
|
||||||
|
|||||||
Reference in New Issue
Block a user