]> WPIA git - motion.git/commitdiff
upd: make sure that database is populated with tables
authorINOPIAE <m.maengel@inopiae.de>
Sat, 29 Aug 2020 04:07:31 +0000 (06:07 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Mon, 31 Aug 2020 10:14:58 +0000 (12:14 +0200)
motion.py

index 05b555a4066b3da88327a63158acb4396bae917c..e2f3f15ab28854e27e927f7260615ed3e696b0d7 100644 (file)
--- a/motion.py
+++ b/motion.py
@@ -113,6 +113,8 @@ def init_db():
             ver = db.prepare("SELECT version FROM schema_version")()[0][0];
             print("Database Schema version: ", ver)
         except postgresql.exceptions.UndefinedTableError:
+            g._database = None
+            db = get_db()
             ver = 0
 
         if ver < 1:
@@ -124,8 +126,8 @@ def init_db():
             with app.open_resource('sql/from_1.sql', mode='r') as f:
                 db.execute(f.read())
                 ct={}
-                for g in [group for group in prefix[app.config.get("DEFAULT_HOST")]]:
-                    ct[g] = {"dt": "", "c": 0}
+                for group in [group for group in prefix[app.config.get("DEFAULT_HOST")]]:
+                    ct[group] = {"dt": "", "c": 0}
 
                 p = db.prepare("UPDATE \"motion\" SET \"identifier\"=$1 WHERE \"id\"=$2")
                 for row in db.prepare("SELECT id, \"type\", \"posed\" FROM \"motion\" ORDER BY \"id\" ASC"):