I have a table with primary keys all set, but I want to run query for data within a time range, so I add column date_query
that store the same data as pk date
from cassandra.cqlengine.columns import Text,Date,DateTime
from cassandra.cqlengine.models import Model
class MyTable(Model):
my_partition_key = Text(primary_key=True, partition_key=True)
date = Text(primary_key=True) # '2023-02-06'
date_query = Date() # '2023-02-06'
time_query = DateTime() # '2023-02-06 21:45:00'
I tried to transform the data in column date_query
into datetime
using datetime.strptime()
, but still it would raise errors that said TypeError: Object of type Timestamp is not JSON serializable
I wish there is a good way to prepare data using python pandas, though I know simply typing strings in CQL would insert the data, but let's pass that.