I have cassandra
model as below.
from uuid import uuid4
from uuid import uuid1
from cassandra.cqlengine import columns, connection
from cassandra.cqlengine.models import Model
from cassandra.cqlengine.management import sync_table
class BaseModel(Model):
__abstract__ = True
id = columns.UUID(primary_key=True, default=uuid4)
created_timestamp = columns.TimeUUID(primary_key=True,
clustering_order='DESC',
default=uuid1)
deleted = columns.Boolean(required=True, default=False)
class OtherModel(BaseModel):
__table_name__ = 'other_table'
name = columns.Text(required=True, default='')
if __name__ == '__main__':
connection.setup(hosts=['localhost'],
default_keyspace='test')
sync_table(OtherModel)
OtherModel.create(id='d43ca2c3-b670-4efc-afd7-b46ada88c3fc', name='test')
When I create record, it set created_timestamp
of my sytem or from where I execute this code.
My system and cassandra
server has different timestamp.
If I execute this where system time is 2017-01-13 10:20:30
then it set timestame as same. and if I again execute same from another system, where timestamp
is 2017-01-13 10:20:20
, then it set same.
When I run query like
select * from test.other_table where id=d43ca2c3-b670-4efc-afd7-b46ada88c3fc limit 1;
It should return me latest
(last) record which inserted last, but as the system timestamp is different from where I inserted record, it gives first record which inserted first.