Skip to content

Commit

Permalink
Merge pull request #1041 from gouzil/master
Browse files Browse the repository at this point in the history
Fix Chinese garbled code and code missed
  • Loading branch information
shiyu22 authored Apr 7, 2022
2 parents dc61f36 + 7f644f2 commit 8ce84cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8ce84cb

Please sign in to comment.