如何在Python 2.7 MySQLdb中使用MYSQL索引

-1 投票
1 回答
745 浏览
提问于 2025-04-18 11:33
indie = '''CREATE FULLTEXT yay ON panda (Question, Answer);'''
cursor.execute(indie)

我已经成功连接到服务器、数据库和表格,一切都正常,但不知道为什么它就是不在表格panda的Question和Answer这两列上创建yay索引。出现了这个错误:

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'yay ON panda (Question, Answer)' at line 1")

我尝试了很多修复的方法,但就是搞不懂。有没有人能帮帮我?

1 个回答

1

你的SQL语法不对,应该是

CREATE FULLTEXT INDEX yay ON panda (Question, Answer);

想了解更多细节,可以查看MySQL的参考手册

撰写回答