自定义cassandra / cqlsh time_format [英] custom cassandra / cqlsh time_format
问题描述
系统:
CentOS 6.7 x86_64
cqlsh 5.0.1 |卡桑德拉2.2.1 | CQL spec 3.3.0
CentOS 6.7 x86_64 cqlsh 5.0.1 | Cassandra 2.2.1 | CQL spec 3.3.0
我在插入(复制csv文件)时间戳字段时遇到问题,格式为'%d-%m-%Y%H:%M :%S',
I'm having problem inserting (copy csv file) timestamp field with the format '%d-%m-%Y %H:%M:%S' ,
默认情况下不支持此格式,因此我在〜/ .cassandra / cqlshrc文件中手动创建了该格式:
This format not supported by default, so I've created it manually in the ~/.cassandra/cqlshrc file:
[ui]
time_format = %d-%m-%Y %H:%M:%S
并再次启动cqlsh,但我仍然无法插入:
and started cqlsh again, but I'm still unable to insert:
system@cqlsh> insert into nir.nir_test (END_DATE) values ('01-09-2015 18:55:50');
InvalidRequest:code = 2200 [Invalid query] message =无法强制执行'01 -09-2015 18:55:50'到格式化日期(长) c
有任何建议吗?
推荐答案
cqlshrc $ c中的
[ui]
配置$ c>仅影响输出格式。查询时间戳列时将应用它。例如:
The [ui]
configuration in cqlshrc
only affects the output format. It gets applied when you query a timestamp column. For example:
select END_DATE from nir.nir_test;
输出功率:
end_date
---------------------
01-09-2015 18:55:50
但是要插入,您需要使用指定的格式。例如:
But for insertion, you need to use one of the specified formats. For example:
insert into nir.nir_test (END_DATE) values ('2015-09-01 18:55:50');
这可能意味着您需要先在CSV文件中转换时间戳,然后再插入
This probably means that you'll need to convert the timestamps in the CSV file before trying to insert them.
这篇关于自定义cassandra / cqlsh time_format的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!