0

嘿 Stackoverflow 通讯,

我正在尝试写入我的 cassandra 数据库,但出了点问题。一些数据:我在 Ubuntu (11.04)、cassandra 0.8.4 和lazyboy 0.7.5 上使用 Python 2.7。当我想写信给卡桑德拉时,我得到了

Traceback (most recent call last):
File "/home/kq/protoWorkspace/indexer/src/database.py", line 40, in <module>
w.save()
File "/usr/local/lib/python2.7/dist-packages/Lazyboy-0.7.5-py2.7.egg/lazyboy/record.py",         
line 202, in save
self._save_internal(self.key, changes, consistency)
File "/usr/local/lib/python2.7/dist-packages/Lazyboy-0.7.5-py2.7.egg/lazyboy/record.py",         
line 236, in _save_internal
key, changes['changed'], consistency))
File "/usr/local/lib/python2.7/dist-packages/Lazyboy-0.7.5-py2.7.egg/lazyboy/connection.py", line 53, in __inner__
raise ex

AttributeError: 'Client' object has no attribute 'batch_insert'

这是我的实际来源:

from lazyboy import *
from lazyboy.key import Key

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

class Indexx(Key):
    def __init__(self, *args, **kwargs):
        Key.__init__(self, "indexer", "indexx", key)

class Word(record.Record):
    _required = ('word', 'docID', 'count',)

    def __init__(self, *args, **kwargs):
        record.Record.__init__(self, *args, **kwargs)
        self.key = Indexx()

w = Word()

print w.key

data = {'word'  : 'test',
        'docID' : 'docId-TEST',
        'count' : 42}

w.update(data)
w.update(data.items())
w.update(**data)
for k in data:
    w[k] = data[k]

w_ = Word(data)
print w_

print w.is_modified()
w.save()

任何想法,我做错了什么?:)

4

1 回答 1

2

主线lazyboy 只支持Cassandra 0.6。我建议改用pycassa。Pycassa 由 DataStax 维护,完全支持最新的 Cassandra 功能。

如果你必须使用lazyboy,有一个fork支持Cassandra 0.7(与0.8 兼容)但开发看起来不是很活跃(5 月最后一次更新)。

于 2011-09-20T13:53:54.887 回答