cassandra.protocol.SyntaxException: 消息="line 0:-1 no viable alternative at input '<EOF>'">

cassandra.protocol.SyntaxException: message="line 0:-1 no viable alternative at input '<EOF>'">

我正在尝试执行这条语句,但我不知道问题出在哪里

prepared = session.prepare("SELECT * FROM recipe WHERE meal = Breakfast")

我遇到了这个错误

cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 0:-1 no viable alternative at input '<EOF>'">

任何帮助将不胜感激

您的 CQL 不正确 - 将 Breakfast 放在单引号中。请参阅 documentation 了解必须如何表示不同的数据类型。

P.S。此外,最好准备一个带有占位符而不是特定值 (where meal = ?) 的查询,并在执行查询时将该值作为参数传递——然后引用等将自动完成。有关示例,请参阅 Python 驱动程序文档