finish env database query

This commit is contained in:
yyc12345 2020-08-11 14:48:04 +08:00
parent bb775e4b20
commit 5a128f5e72
4 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,10 @@
import locale
# encoding list
# https://docs.python.org/3/library/codecs.html#standard-encodings
database_encoding = locale.getpreferredencoding()
export_db = "export.db"
decorated_db = "decorate.db"
env_db = "env.db"
force_regenerate = False

View File

@ -6,7 +6,7 @@ import Progressbar
def run():
exportDb = sqlite3.connect(CustomConfig.export_db)
exportDb.text_factory = lambda x: x.decode(CustomConfig.database_encoding)
exportDb.text_factory = lambda x: x.decode(CustomConfig.database_encoding, errors="ignore")
decorateDb = sqlite3.connect(CustomConfig.decorated_db)
# init table

View File

@ -26,7 +26,7 @@ def get_env():
env = getattr(g, '_envDatabase', None)
if env is None:
env = g._envDatabase = sqlite3.connect(CustomConfig.env_db)
env.text_factory = lambda x: x.decode(CustomConfig.database_encoding)
env.text_factory = lambda x: x.decode(CustomConfig.database_encoding, errors="ignore")
return env
@app.teardown_appcontext
@ -102,7 +102,7 @@ def envQueryHandle():
if fieldLength == 0:
cur.execute("SELECT * FROM {}".format(queryTag))
else:
whereStatement = '&&'.join(map(lambda x: "([" + x + "] = ?)", readyData.keys()))
whereStatement = 'AND'.join(map(lambda x: "([" + x + "] = ?)", readyData.keys()))
cur.execute("SELECT * FROM {} WHERE ({})".format(queryTag, whereStatement), list(readyData.values()))
# iterate

View File

@ -3,7 +3,7 @@ table.envOutput {
}
table.envOutput tr:nth-child(odd) {
background:gray;
background:#cfcfcf;
}
table.envOutput tr:nth-child(2n) {