このコードInternalError:(1242 'サブクエリが1行以上を返す')
conn = pymysql.connect(user = 'root', password = '', unix_socket = "/tmp/mysql.sock", database = 'abc')
cursor = conn.cursor()
query2 = """INSERT INTO paragraphVector (termId, termFreq, kgram) VALUES ((SELECT termId FROM term WHERE term = %s AND kgram = %s), %s, %s)"""
insertDocVec = [(str(term), str(kgram), tf[kgram][term], str(kgram)) for kgram in tf for term in tf[kgram]]
cursor.executemany(query2, insertDocVec)
conn.commit()
おそらく選択が2行以上返し、これがエラーメッセージの原因です。構文を 'insert ... select ... 'に変更したい場合は、変更後に – Shadow