Cassandra与Lazyboy的TimeUUID

2024-10-01 00:14:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试插入带有UUID1键的列,以便能够按日期对它们进行排序。我总是犯错误”cassandra.ttypes.InvalidRequestException:InvalidRequestException(why='UUIDs must exactly 16 bytes')”,我不知道为什么。在

以下是生成此错误的代码:

from lazyboy import *
from lazyboy.key import Key
import uuid

class TestItemKey(Key):
    def __init__(self, key=None):
        Key.__init__(self, 'MXstore', 'TestCF', key)

class TestItem(record.Record):
    def __init__(self, *args, **kwargs):
        record.Record.__init__(self, *args, **kwargs)
        self.key = TestItemKey(uuid.uuid1().bytes)

connection.add_pool('MXstore', ['localhost:9160'])

tmp = {'foo' : 'bar'}
tmps = TestItem(tmp).save()

我做错什么了?我用lazyboy 0.705和Cassandra 0.6.4。 存储配置为:

^{pr2}$

Tags: keyfromimportselfbytesuuidinitdef