我在python中有一个MYSQL查询。它运行良好。但是,在删除表中的某个元组之后,会出现以下错误。_mysql_exceptions.OperationalError:(1271,“非法混合操作排序”IN)“python
以下是我的代码到目前为止。
with open('out.csv', 'rb') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
text=(row['text'])
emotion = (row['emotion'])
my_list = (text, emotion)
my_array = np.asarray(my_list)
sentence = (text.lower())
w_tokenize = (word_tokenize(sentence))
negation_words = [w for i, w in enumerate(w_tokenize) if i and (
w_tokenize[i - 1] in ["not", "never", "no", "nobody", "nothing", "neither", "doesn't", "isn't", "wasn't",
"shouldn't", "wouldn't", "couldn't", "won't", "can't", "don't", "didn't"])]
if w_tokenize== []:
Value = ''
else:
cursor = conn.cursor()
format_strings = ','.join(['%s'] * len(w_tokenize))
cursor.execute("SELECT emotion_type FROM emotion WHERE key_word IN (%s)" % format_strings,
tuple(w_tokenize))
results = [res[0] for res in cursor.fetchall()]
if results:
frequencies = Counter(results)
Value = max(frequencies, key=frequencies.get)
else:
Value = ''
但我找不到解决方案。谁能帮我。
你能分享你的'w_tokenize'吗? –