schema - Create and change to new keyspace with Cassandra cqlengine? -


let's connect cassandra cluster:

cqlengine.connection.setup('hostname', 'some_keyspace') 

the method requires know @ least 1 existing keyspace. if don't?

what if wish check if keyspace exists , create otherwise?

we create keyspace this:

cqlengine.management.create_keyspace('keyspace_name', some_other_args) 

so there 3 questions here:

  1. how connect without supplying keyspace?
  2. what correct way create new keyspace (what other arguments besides name of keyspace)?
  3. how switch keyspaces using cqlengine?

  1. you need 'default' keyspace. can exists. think cassandra have default keyspaces.

  2. the correct way create keyspace using create_keyspace_simple command:

    from cassandra.cqlengine.management import create_keyspace_simple  create_keyspace_simple(keyspace_name, replication_factor) 
  3. to change keyspace:

    from cassandra.cqlengine import models  models.default_keyspace = keyspace_name 

    assuming connection imported , have defined keyspace_name


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -