From 5a128f5e72f82aab8a3b661f59ef8edf5cf00a05 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Tue, 11 Aug 2020 14:48:04 +0800 Subject: [PATCH] finish env database query --- SuperScriptViewer/CustomConfig.py | 5 ++++- SuperScriptViewer/DecoratorCore.py | 2 +- SuperScriptViewer/ServerCore.py | 4 ++-- SuperScriptViewer/static/env.css | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/SuperScriptViewer/CustomConfig.py b/SuperScriptViewer/CustomConfig.py index 1bde382..df0e4c4 100644 --- a/SuperScriptViewer/CustomConfig.py +++ b/SuperScriptViewer/CustomConfig.py @@ -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 \ No newline at end of file +force_regenerate = False + diff --git a/SuperScriptViewer/DecoratorCore.py b/SuperScriptViewer/DecoratorCore.py index 7e82249..099718a 100644 --- a/SuperScriptViewer/DecoratorCore.py +++ b/SuperScriptViewer/DecoratorCore.py @@ -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 diff --git a/SuperScriptViewer/ServerCore.py b/SuperScriptViewer/ServerCore.py index e28fa88..997ff70 100644 --- a/SuperScriptViewer/ServerCore.py +++ b/SuperScriptViewer/ServerCore.py @@ -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 diff --git a/SuperScriptViewer/static/env.css b/SuperScriptViewer/static/env.css index e0c4738..17cc198 100644 --- a/SuperScriptViewer/static/env.css +++ b/SuperScriptViewer/static/env.css @@ -3,7 +3,7 @@ table.envOutput { } table.envOutput tr:nth-child(odd) { - background:gray; + background:#cfcfcf; } table.envOutput tr:nth-child(2n) {