0

I have a simple code written in C for inserting local date and time into Cassandra's timestamp column as follows:

time_t rt= time(NULL);
struct tm * timeinfo;
timeinfo = localtime ( &rt );
char lt[20];
strftime(lt, sizeof(lt), "%Y-%m-%d %T", timeinfo);

 const char* query = "INSERT INTO time_table(id,time) VALUES(now(),?);";

          CassStatement* statement = cass_statement_new(query, 1);
          cass_statement_bind_string(statement,0,lt);


          CassFuture* result_future = cass_session_execute(session, statement);

But this code is not able to insert anything inside time_table. If I try to insert the same thing using cqlsh using the query insert into time_table(id,time) values(now(),'2019-09-04 10:59:22');, then the values are getting inserted without any problem. I am using Cassandra driver for C version 2.13.

Can anyone please point out the mistake in the code?

4

0 回答 0