15 lines
416 B
Python
15 lines
416 B
Python
from flask import g
|
|
from sqlite import SQLite
|
|
import json
|
|
|
|
def get_db():
|
|
db = getattr(g, "_database", None)
|
|
|
|
if db is None:
|
|
with open('../../config.json') as config_file:
|
|
config_json = json.load(config_file.read())
|
|
|
|
if str(config_json["database"]["type"]).casefold() == "SQLite".casefold():
|
|
db = g._database = SQLite(config_json["database"]["name"])
|
|
|
|
return db |