保存到cassandra时的Lazyboy AttributeError

时间:2011-09-19 08:17:54

标签: python cassandra attributeerror

Hey Stackoverflow comm,

我正在尝试写入我的cassandra数据库,但事情正在发生 错误..一些数据:我在Ubuntu(11.04)上使用Python 2.7,cassandra 0.8.4和lazyboy 0.7.5。虽然我想写信给cassandra但我得到了

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()

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

1 个答案:

答案 0 :(得分:2)

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

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