Reputation: 374
This is my Database Structure
CREATE TABLE stack (
id UUID,
entrytime TIMESTAMP,
name TEXT,
PRIMARY KEY (id, entrytime)
) WITH CLUSTERING ORDER BY ( entrytime DESC );
And when I use the Insert statement as.
INSERT INTO stack ( id, entrytime, name )
VALUES ( now(), toTimestamp( now() ), 'Nik' );
But it stores the entry time column as 2018-01-15 08:29:58.174000+0000
I want to remove the extra precision that Cassandra provides.
I know this has to do something with the cqlshrc.sample
file but I am not able to do it.
Can anyone help me out here?
This is a portion of my cqlshrc file
[ui]
;; Whether or not to display query results with colors
; color = on
;; Used for displaying timestamps (and reading them with COPY)
time_format = %Y-%m-%d %H:%M:%S
;; Display timezone
;timezone = Etc/UTC
Now when I run my cql shell then following error occurs.
Traceback (most recent call last):
File "/var/www/html/cassandra/apache-cassandra-
3.11.1/bin/cqlsh.py", line 2434, in <module>
main(*read_options(sys.argv[1:], os.environ))
File "/var/www/html/cassandra/apache-cassandra-
3.11.1/bin/cqlsh.py", line 2211, in read_options
configs.read(CONFIG_FILE)
File "/usr/lib/python2.7/ConfigParser.py", line 305, in read
self._read(fp, filename)
File "/usr/lib/python2.7/ConfigParser.py", line 512, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
ConfigParser.MissingSectionHeaderError: File contains no section headers.
file: /home/ubuntu/.cassandra/cqlshrc, line: 1
'\xef\xbb\xbf; Licensed to the Apache Software Foundation (ASF) under one\n'
Upvotes: 1
Views: 1156
Reputation: 87369
Just insert into ~/.cassandra/cqlshrc
file, into [ui]
section following line (this is for 3.x):
time_format = %Y-%m-%d %H:%M:%S%z
Description of %
fields you can find here.
P.S. I've modified the answer because the datetimeformat
is used only in COPY FROM
's options, not in the cqlshrc
...
Upvotes: 2