From e51dd85d540e1fda35e2dee348087b2b57933840 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Tue, 25 Jul 2023 16:10:09 -0700 Subject: [PATCH] Add hashbang, script description, and useful error message to convert_db script Signed-off-by: Alek Ratzloff --- convert_db.py | 8 ++++++++ 1 file changed, 8 insertions(+) mode change 100644 => 100755 convert_db.py diff --git a/convert_db.py b/convert_db.py old mode 100644 new mode 100755 index b4f9c0a..bc4a69a --- a/convert_db.py +++ b/convert_db.py @@ -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 sqlite3 @@ -52,6 +56,10 @@ bans = old_db.execute("SELECT * FROM BANS").fetchall() print("Converting", len(bans), "rows") 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["action"] = ban["action"] # post['board'] = ban['board']