我正在使用版本 2.0.1 和带有1.4 库的Cassandra
python 。cql
这是表的描述instruments
:
CREATE TABLE instruments (
key text,
field text,
valid_date timestamp,
publication_date timestamp,
insertion_date timestamp,
value text,
PRIMARY KEY (key, field, valid_date, publication_date, insertion_date)
) WITH CLUSTERING ORDER BY (field ASC, valid_date DESC, publication_date DESC, insertion_date DESC) AND
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
index_interval=128 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
default_time_to_live=0 AND
speculative_retry='NONE' AND
memtable_flush_period_in_ms=0 AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'LZ4Compressor'};
将 cqlsh 与查询一起使用:
select key, field, valid_date, publication_date, insertion_date, value from instruments where key='instrument1' and field='currency' and valid_date <= 1376524800000;
我有结果
key | field | valid_date | publication_date | insertion_date | value
-------------+----------+--------------------------+--------------------------+--------------------------+-------
instrument1 | currency | 2013-08-15 02:00:00+0200 | 2013-08-15 02:00:00+0200 | 2013-08-15 02:00:00+0200 | USD
但是在 python 程序中使用 cql 时,我得到了:
list: [u'instrument1', u'currency', '\x00\x00\x01@\x7fE\x90\x00', '\x00\x00\x01@\x7fE\x90\x00', '\x00\x00\x01@\x7fE\x90\x00', u'USD']
如何正确地从数据库中检索结果?当我将 casssandra 服务器升级到 2.0 时出现此问题