python - How to insert a datetime into a Cassandra 1.2 timestamp column -


important if dealing problem today, use new cassandra-driver datastax (i.e. import cassandra) since solves of common problems , don't use old cql driver anymore, obsolete! question old before new driver in development , had use incomplete old library called cql (import cql <-- don't use anymore, move new driver).

intro i'm using python library cql access cassandra 1.2 database. in database have table timestamp column , in python code have datetime inserted in column. example follows:

table

create table test (      id text primary key,      last_sent timestamp ); 

the code

import cql import datetime ... cql_statement = "update test set last_sent = :last_sent id =:id" rename_dict = {} rename_dict['id'] = 'someid' rename_dict['last_sent'] = datetime.datetime.now() cursor.execute (cql_statement, rename_dict) 

the problem

when execute code actual cql statement executed this:

update test set last_sent =2013-05-13 15:12:51 id = 'someid' 

then fails error

 bad request: line 1:xx missing eof @ '-05' 

the problem seems cql library not escaping ('') or converting datetime before running query.

the question correct way of doing without manually escaping date , able store full timestamp more precision cassandra timestamp column?

thanks in advance!

i can tell how in cqlsh. try this

update test set last_sent =1368438171000 id = 'someid' 

equivalent long value date time 2013-05-13 15:12:51 1368438171000


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -