From bf44885ec94666a5f951a2eaa9c50c4fd1b2ebee Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Wed, 20 Sep 2023 18:50:35 +0200 Subject: [PATCH] mate.db wird erstellt, wenn nicht existent --- Website/db.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Website/db.py b/Website/db.py index 23f4a5c..6ae047e 100644 --- a/Website/db.py +++ b/Website/db.py @@ -1,3 +1,4 @@ +from re import M import sqlite3 import click @@ -6,10 +7,17 @@ from flask import current_app, g def get_db(): if 'db' not in g: - g.db = sqlite3.connect( - current_app.config['DATABASE'], - detect_types=sqlite3.PARSE_DECLTYPES - ) + try: + g.db = sqlite3.connect( + current_app.config['DATABASE'], + detect_types=sqlite3.PARSE_DECLTYPES + ) + except: + init_db() + g.db = sqlite3.connect( + current_app.config['DATABASE'], + detect_types=sqlite3.PARSE_DECLTYPES + ) g.db.row_factory = sqlite3.Row return g.db