1

我正在尝试使用 cassandra 通过 kafka 连接 Meetup 流 api。cqlengine似乎它以前是一个单独的项目,而我使用的参考代码是在那个时候制作的。

所以以前,cqlengine.managementcreate_keyspace 现在,cassandra.cqlengine.managementcreate_keyspace_simple

我正在尝试创建键空间。

create_keyspace_simple('meetup', 'SimpleStrategy', 1)

但是,然后我得到了这个错误。警告:

/Users/a/anaconda/lib/python2.7/site-packages/cassandra/cqlengine/management.py:419:UserWarning:CQLENG_ALLOW_SCHEMA_MANAGEMENT 环境变量未设置。此软件包的未来版本将需要此变量来启用管理功能。
警告。警告(味精)

错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-45553511338c> in <module>()
      1 # create keyspace
      2 # keyspace name, keyspace replication strategy, replication factor
----> 3 create_keyspace_simple('meetup', 'SimpleStrategy', 1)

/Users/a/anaconda/lib/python2.7/site-packages/cassandra/cqlengine/management.pyc in create_keyspace_simple(name, replication_factor, durable_writes)
     54     """
     55     _create_keyspace(name, durable_writes, 'SimpleStrategy',
---> 56                      {'replication_factor': replication_factor})
     57 
     58 

/Users/a/anaconda/lib/python2.7/site-packages/cassandra/cqlengine/management.pyc in _create_keyspace(name, durable_writes, strategy_class, strategy_options)
     84         log.info("Creating keyspace %s ", name)
     85         ks_meta = metadata.KeyspaceMetadata(name, durable_writes, strategy_class, strategy_options)
---> 86         execute(ks_meta.as_cql_query())
     87     else:
     88         log.info("Not creating keyspace %s because it already exists", name)

/Users/a/anaconda/lib/python2.7/site-packages/cassandra/metadata.so in cassandra.metadata.KeyspaceMetadata.as_cql_query (cassandra/metadata.c:17371)()

AttributeError: 'NoneType' object has no attribute 'export_for_schema'
4

1 回答 1

0

根据文档的外观,create_keyspace_simple接受以下参数列表:

create_keyspace_simple(name, replication_factor, durable_writes=True)
  • name (str) - 要创建的键空间的名称
  • replication_factor (int) - 键空间复制因子,与 SimpleStrategy 一起使用
  • Durable_writes (bool) - 如果设置为 False,则绕过写入日志

基于此,我认为如果您删除“SimpleStrategy”参数,您的声明将起作用。由于您使用create_keyspace_simple的是 ,因此 SimpleStrategy 是隐含的,因此您无论如何都不需要指定它。

create_keyspace_simple('meetup', 1)
于 2016-02-28T21:16:45.060 回答