A number of database related additions
This commit is contained in:
@@ -21,6 +21,8 @@ class SQLite(Database):
|
||||
rows = list(cursor)
|
||||
|
||||
return (len(rows), rows)
|
||||
elif query.casefold().startswith("INSERT".casefold()):
|
||||
return (cursor.lastrowid, None)
|
||||
else:
|
||||
return (cursor.rowcount, None)
|
||||
|
||||
|
||||
15
utilities/database/tools.py
Normal file
15
utilities/database/tools.py
Normal file
@@ -0,0 +1,15 @@
|
||||
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
|
||||
Reference in New Issue
Block a user