我有 cqlsh 的编码问题。

当我尝试使用 CQLSH 命令插入带有特殊字符的文本数据时:

cqlsh localhost -k my_keyspace -f /home/me/workspace/scripts/test.cql

(test.cql 包含以下行):
INSERT INTO table_content (tableId, title, content) VALUES ('record1', 'Mon titre', 'Mon contenu avec un accent évidemment');

我收到以下错误:
Traceback (most recent call last):
File "/opt/applications/apache-cassandra-2.1.8/bin/cqlsh", line 2459, in <module>
main(*read_options(sys.argv[1:], os.environ))
File "/opt/applications/apache-cassandra-2.1.8/bin/cqlsh", line 2451, in main
shell.cmdloop()
  File "/opt/applications/apache-cassandra-2.1.8/bin/cqlsh", line 940, in cmdloop
    line = self.get_input_line(self.prompt)
  File "/opt/applications/apache-cassandra-2.1.8/bin/cqlsh", line 909, in get_input_line
    self.lastcmd = self.stdin.readline()
  File "/usr/lib/python2.7/codecs.py", line 672, in readline
    return self.reader.readline(size)
  File "/usr/lib/python2.7/codecs.py", line 527, in readline
    data = self.read(readsize, firstline=True)
  File "/usr/lib/python2.7/codecs.py", line 474, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 26: ordinal not in range(128)

不过,我的文件是用 UTF-8 编码的。
知道如何为 cqlsh 命令行强制使用 UTF-8 编码吗?我使用以下版本(我没有选择):[cqlsh 5.0.1 | Cassandra 2.1.8 | CQL 规范 3.2.0 | native 协议(protocol) v3]

最佳答案

cql 5.0.1 中存在问题,现在处于已解决状态。
如果您无法升级,则提到以下解决方案:

More Details

关于encoding - 带有特殊字符的 CQLSH 问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36305025/

10-16 13:47