diff --git a/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py b/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py index a9385041b..2ce8ef815 100644 --- a/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py +++ b/solutions/question_answering_system/quick_deploy/server/src/milvus_helpers.py @@ -56,6 +56,7 @@ def insert(self, collection_name, vectors): try: self.create_collection(collection_name) data = [vectors] + self.set_collection(collection_name) mr = self.collection.insert(data) ids = mr.primary_keys self.collection.load() diff --git a/solutions/question_answering_system/quick_deploy/server/src/mysql_helpers.py b/solutions/question_answering_system/quick_deploy/server/src/mysql_helpers.py index 6cbeede8f..78d96face 100644 --- a/solutions/question_answering_system/quick_deploy/server/src/mysql_helpers.py +++ b/solutions/question_answering_system/quick_deploy/server/src/mysql_helpers.py @@ -42,6 +42,7 @@ def load_data_to_mysql(self, table_name, data): # Batch insert (Milvus_ids, img_path) to mysql self.test_connection() sql = "insert into " + table_name + " (milvus_id,question,answer) values (%s,%s,%s);" + self.cursor.execute('SET character_set_connection=utf8;') try: self.cursor.executemany(sql, data) self.conn.commit() @@ -71,7 +72,10 @@ def search_by_question(self, question, table_name): self.cursor.execute(sql) results = self.cursor.fetchall() LOGGER.debug("MYSQL search by question.") - return results[0][0] + if results: + return results[0][0] + else: + return results except Exception as e: LOGGER.error(f"MYSQL ERROR: {e} with sql: {sql}".format(e, sql)) sys.exit(1)