A bunch of random crap working towards the first (simplest) upload mechanism
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
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
|
||||
21
utilities/tools.py
Normal file
21
utilities/tools.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from flask import g
|
||||
from database.sqlite import SQLite
|
||||
import json
|
||||
|
||||
def get_config():
|
||||
config = getattr(g, "_config", None)
|
||||
|
||||
if config is None:
|
||||
with open("../config.json") as config_file:
|
||||
config = g._config = json.loads(config_file.read())
|
||||
|
||||
return config
|
||||
|
||||
def get_db():
|
||||
db = getattr(g, "_database", None)
|
||||
|
||||
if db is None:
|
||||
if str(get_config()["database"]["type"]).casefold() == "SQLite".casefold():
|
||||
db = g._database = SQLite(get_config()["database"]["name"])
|
||||
|
||||
return db
|
||||
Reference in New Issue
Block a user