Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

nebula_exec procedure

The nebula_exec procedure executes a GQL query on a remote NebulaGraph Database Developer Edition cluster. You can use this procedure to import data into a graph in NebulaGraph Database Developer Edition.

Procedure signature

nebula_exec(nebula_uri_string: String, gql: String)

Parameters

nebula_uri_string

The URI string used to connect to NebulaGraph Database Developer Edition.

The format of the URI is as follows:

nebula_uri_string
nebula:// username : password @ graph_address ? tls_parameter_name = tls_parameter_value &

nebula_uri_string ::= 
    'nebula://' username ':' password '@' graph_address ('?' ( tls_parameter_name '=' tls_parameter_value) ('&' ( tls_parameter_name '=' tls_parameter_value))* )?

username

The username used to connect to NebulaGraph Database Developer Edition.

password

The current password for the account used to connect to the remote instance.

graph_address

The address of the Graph service in NebulaGraph Database Developer Edition. Format: ip:port.

tls_parameter_name and tls_parameter_value

The parameters used to configure TLS when connecting to the Graph service. For the complete list of TLS parameters, see tls_parameter_name and tls_parameter_value.

gql

The GQL query to be executed.

Examples

Perform a DDL operation

Replace <current-password> in the URI with the current password for the account you use to access the remote instance. If the password has changed, use the new password.

CALL nebula_exec('nebula://root:<current-password>@192.168.8.129:10005', 'CREATE GRAPH IF NOT EXISTS test_movie TYPED movie_type') FINISH

Perform an insert operation

'''
CALL nebula_exec('nebula://root:<current-password>@192.168.8.129:10005', '
  USE test_movie
  INSERT OR REPLACE
    (@Director{id:111, name:"Alice", birthDate:date("1990-01-01")}), 
    (TYPED Actor{id:222, name:"Bob", birthDate:date("1990-01-02")})
  ') FINISH
'''

Perform an update operation

'''
CALL nebula_exec('nebula://root:<current-password>@192.168.8.129:10005', '
  USE test_movie
  MATCH (v@Actor{id:222}) SET v.name = "Charlie"
  ') FINISH
'''

Perform a delete operation

'''
CALL nebula_exec('nebula://root:<current-password>@192.168.8.129:10005', '
  USE test_movie
  MATCH (v@Actor{id:222}) DELETE v
  ') FINISH
'''

Perform a batch update operation

The following example is based on the temporary graph #movie_temporary_graph created in CREATE TEMPORARY GRAPH.

'''
USE #movie_temporary_graph {
TABLE t {id INT, name STRING} 
VALUE fmt_query = "
      TABLE t TYPED TABLE {id INT, name STRING} = %s
      USE test_movie
      FOR r IN t
      MATCH (a@Movie) WHERE a.id = r.id
      SET a.name = r.name"

MATCH (a@Movie)
PER NODE (a) {
      EXPORT a.id, "Movie_" || CAST(a.id as STRING) INTO t
}

FOR split IN table_split(t, CAST(256 as UINT))
CALL nebula_exec("nebula://root:<current-password>@192.168.8.129:10005", fmt(fmt_query, to_literal(split))) FINISH
}
'''

The preceding example writes locally computed graph results back to a remote NebulaGraph Database Developer Edition cluster in batches. It iterates over all Movie nodes in the temporary graph, generates a new name for each node (in the format Movie_<ID>), splits the data into batches of up to 256 rows, and sends the update statements to the remote NebulaGraph Database Developer Edition cluster via the nebula_exec procedure to batch-update the name property of corresponding Movie nodes in the test_movie graph.