cquengine sync_table()键错误:“cquengine”

2024-05-14 12:01:50 发布

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

我刚刚开始使用cquengine在python中使用Cassandra。在

我试着按照这个link运行这个脚本:

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)

但它会产生这样的错误:

^{pr2}$

我的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

请帮助我理解和解决这个问题。 谢谢。在


Tags: columnsfromimporttruemodeluuidexampletable
2条回答

编辑:在cquengine 0.21中,create_missing_keyspace被忽略,而不是0.20。尝试使用cquengine的0.21版本或手动创建(见下文)。在

创建键空间like this

cqlengine.management.create_keyspace("cqlengine", replication_factor=1, strategy_class="SimpleStrategy")

可用的策略是^{}和{a3}。在

我找不到0.21的更新文档,所以我检查了the source。以下是0.21中create_keyspace的声明:

^{pr2}$

这件事在我这边被忽视了-我现在正在修理。create_missing_keystpace很少“做正确的事情”,而且修复使用错误参数创建的键空间非常困难和耗时。现在必须显式地使用所需的参数创建一个键空间。在

相关问题 更多 >

    热门问题