def keyspace_exists(keyspace, contact_points=None, port=None, cql_user=None, cql_pass=None):
 query = "select keyspace_name\n                 from system.schema_keyspaces\n                where keyspace_name = '{0}';".format(keyspace)
 try:
  ret = cql_query(query, contact_points, port, cql_user, cql_pass)
 except CommandExecutionError:
  log.critical('Could not determine if keyspace exists.')
  raise
 except BaseException as e:
  log.critical('Unexpected error while determining if keyspace exists: {0}'.format(str(e)))
  raise
 return (True if ret else False)

def keyspace_exists ( keyspace , contact_points = None , port = None , cql_user = None , cql_pass = None ) : query = "select keyspace_name\n                 from system.schema_keyspaces\n                where keyspace_name = '{0}';" . format ( keyspace ) try : ret = cql_query ( query , contact_points , port , cql_user , cql_pass ) except CommandExecutionError : log . critical ( 'Could not determine if keyspace exists.' ) raise except BaseException as e : log . critical ( 'Unexpected error while determining if keyspace exists: {0}' . format ( str ( e ) ) ) raise return ( True if ret else False )
check if a keyspace exists in a cassandra cluster .