我刚刚开始使用 cqlengine 在 python 中使用 Cassandra。
我尝试关注此链接并尝试运行此脚本:
from cqlengine import columns
from cqlengine import Model
from cqlengine import connection
from cqlengine.management import sync_table
import uuid
class ExampleModel(Model):
example_id = columns.UUID(primary_key=True, default=uuid.uuid4)
example_type = columns.Integer(index=True)
created_at = columns.DateTime()
description = columns.Text(required=False)
connection.setup(['127.0.0.1'], 'cqlengine')
sync_table(ExampleModel)
但它抛出了这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/zopper/Desktop/django-cassandra/local/lib/python2.7/site-packages/cqlengine/management.py", line 92, in sync_table
keyspace = cluster.metadata.keyspaces[ks_name]
KeyError: 'cqlengine'
我pip freeze
的是:
Django==1.7.3
argparse==1.2.1
blist==1.3.6
cassandra-driver==2.1.3
cqlengine==0.21.0
django-cassandra-engine==0.2.1
djangotoolbox==1.6.2
futures==2.2.0
six==1.9.0
wsgiref==0.1.2
请帮助我理解并解决这个问题。谢谢。