0

I need to execute the following query:

CREATE (m: Temp {val1: <variable>})

I know there exists save_node functionality but I don't want to use that. I tried the following syntax but it didn't work

connection.execute("CREATE (m: Temp {{val1: variable}}})

This seems to work only if the variable is a for loop iterator.

KWriter
  • 1,024
  • 4
  • 22

1 Answers1

0

You are missing a quatation mark at the end of the command as well as qurly brackets around variable. Here is an example:

 from gqlalchemy import Memgraph

 print("Connect")
 memgraph = Memgraph()

 print("Create a node")
 variable = 100
 memgraph.execute(f"CREATE (m: Temp {{val1: {variable}}});")
KWriter
  • 1,024
  • 4
  • 22