【问题标题】:CQLSH issue with special characters带有特殊字符的 CQLSH 问题
【发布时间】:2016-07-18 05:33:55
【问题描述】:

我有 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 |卡桑德拉 2.1.8 | CQL 规范 3.2.0 |原生协议 v3]

【问题讨论】:

    标签: encoding cassandra cqlsh


    【解决方案1】:

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

    已通过更改 cqlsh.py 的第 1135 行来纠正该问题

    readline.add_history(new_hist) -> readline.add_history(new_hist.encode('utf8'))

    More Details

    【讨论】:

    • 好的,谢谢。我想这解决了我的问题,但我无权应用此类补丁。还是谢谢。
    猜你喜欢
    • 1970-01-01
    • 2016-03-07
    • 2021-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多