1

I'm trying to use cassandra to connect with Meetup streaming api through kafka. cqlengine seems like that it was an separated project before and the reference code that I am using is made around that time.

So before, cqlengine.management had create_keyspace Now, cassandra.cqlengine.management has create_keyspace_simple

I am trying to create keyspace.

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

However, then I got this error. Warning:

/Users/a/anaconda/lib/python2.7/site-packages/cassandra/cqlengine/management.py:419: UserWarning: CQLENG_ALLOW_SCHEMA_MANAGEMENT environment variable is not set. Future versions of this package will require this variable to enable management functions.
warnings.warn(msg)

Error:

---------------------------------------------------------------------------
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'
Cœur
  • 37,241
  • 25
  • 195
  • 267
user3368526
  • 2,168
  • 10
  • 37
  • 52

1 Answers1

0

By the looks of the documentation, create_keyspace_simple accepts the following parameter list:

create_keyspace_simple(name, replication_factor, durable_writes=True)
  • name (str) - name of keyspace to create
  • replication_factor (int) - keyspace replication factor, used with SimpleStrategy
  • durable_writes (bool) - Write log is bypassed if set to False

Based on this, I think your statement will work if you remove the 'SimpleStrategy' parameter. Since you're using create_keyspace_simple, the SimpleStrategy is implied, so you shouldn't need to specify it anyway.

create_keyspace_simple('meetup', 1)
Aaron
  • 55,518
  • 11
  • 116
  • 132