def create_keyspace(keyspace, replication_strategy='SimpleStrategy', replication_factor=1, replication_datacenters=None, contact_points=None, port=None, cql_user=None, cql_pass=None):
 existing_keyspace = keyspace_exists(keyspace, contact_points, port)
 if (not existing_keyspace):
  replication_map = {'class': replication_strategy}
  if replication_datacenters:
   if isinstance(replication_datacenters, six.string_types):
    try:
     replication_datacenter_map = json.loads(replication_datacenters)
     replication_map.update(**replication_datacenter_map)
    except BaseException:
     log.error('Could not load json replication_datacenters.')
     return False
   else:
    replication_map.update(**replication_datacenters)
  else:
   replication_map['replication_factor'] = replication_factor
  query = 'create keyspace {0}\n                     with replication = {1}\n                      and durable_writes = true;'.format(keyspace, replication_map)
  try:
   cql_query(query, contact_points, port, cql_user, cql_pass)
  except CommandExecutionError:
   log.critical('Could not create keyspace.')
   raise
  except BaseException as e:
   log.critical('Unexpected error while creating keyspace: {0}'.format(str(e)))
   raise

def create_keyspace ( keyspace , replication_strategy = 'SimpleStrategy' , replication_factor = 1 , replication_datacenters = None , contact_points = None , port = None , cql_user = None , cql_pass = None ) : existing_keyspace = keyspace_exists ( keyspace , contact_points , port ) if ( not existing_keyspace ) : replication_map = { 'class' : replication_strategy } if replication_datacenters : if isinstance ( replication_datacenters , six . string_types ) : try : replication_datacenter_map = json . loads ( replication_datacenters ) replication_map . update ( ** replication_datacenter_map ) except BaseException : log . error ( 'Could not load json replication_datacenters.' ) return False else : replication_map . update ( ** replication_datacenters ) else : replication_map [ 'replication_factor' ] = replication_factor query = 'create keyspace {0}\n                     with replication = {1}\n                      and durable_writes = true;' . format ( keyspace , replication_map ) try : cql_query ( query , contact_points , port , cql_user , cql_pass ) except CommandExecutionError : log . critical ( 'Could not create keyspace.' ) raise except BaseException as e : log . critical ( 'Unexpected error while creating keyspace: {0}' . format ( str ( e ) ) ) raise
create a new keyspace in cassandra .