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