我有一个文本文件' hi.txt'它有:
i have a friendy whosr name is winy.And has a friend who is greatly.
我有一个数据库表testtb
testid test1
1 hello
2 hi
3 friend
4 great
5 win
我想将输出打印为:
friendy
winy
greatly
我想使用全文索引打印所有行的相似单词。它不仅用于给定示例,所以不要单独限制此示例。请回答!
我创建了一个程序:
import MySQLdb
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="mysql", # your password
db="sakila")
with open('qwer2.txt','r') as file, db as cursor:
for line in file:
query=SELECT * FROM testtb WHERE MATCH (test1) AGAINST (line)
if key in keywords:
print key
cursor.execute(query)
它没有产生任何输出,所以请帮助!答案将不胜感激。