cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 1: replicate users.

Creating relations between countries in neo4j using python

laureee777
Node Link

Hi,

I need help with creating relations between countries in neo4j using python. I have a code, but in neo4j browser it doesn't create relations.

from neo4j import GraphDatabase
driver = GraphDatabase.driver("neo4j://localhost:7687",
                              auth=("neo4j", "test"))

def create_country(tx, name,continent,population_mln,govrm_system,bcountry):
    tx.run("CREATE (a:Country {name: $name,continent: $continent,population_mln: $population_mln,govrm_system:$govrm_system,bcountry: $bcountry})",
           name=name,continent=continent,population_mln=population_mln,govrm_system=govrm_system,bcountry=bcountry)

with driver.session() as session:
    session.execute_write(create_country, "russia","Asia",143,"terrorist state",["Kazakhstan","Lithuania","Finland","China","Japan"])
    session.execute_write(create_country, "India","Asia",1393,"Parliamentary Republic","China")
    session.execute_write(create_country, "China","Asia",1412,"One-party state",["India","russia","Philipines","Japan"])
    session.execute_write(create_country, "Poland","Europe",37,"Parliamentary Republic",["Lithuania","Germany","Czechia"])
    session.execute_write(create_country, "Kazakhstan","Asia",19,"Presidential system Republic","russia")
    session.execute_write(create_country, "Lithuania","Europe",2.7,"Parliamentary Republic",["russia","Poland"])
    session.execute_write(create_country, "Finland","Europe",5.5,"Parliamentary Republic","russia")
    session.execute_write(create_country, "Philipines","Asia",111,"Parliamentary Republic",["Japan","China"])
    session.execute_write(create_country, "Japan","Asia",125,"Constitutional Monarchy",["Philipines","China","russia"])
    session.execute_write(create_country, "Germany","Europoe",83,"Parliamentary Republic",["Czechia","Austria","Poland"])
    session.execute_write(create_country, "Czechia","Europoe",10,"Parliamentary Republic",["Austria","Poland","Germany"])
    session.execute_write(create_country, "Austria","Europoe",9,"Parliamentary Republic",["Czechia","Germany"])

def create_bordering_country(tx, name, bcountry):
    tx.run("FOREACH (n IN a.bcountry | MERGE (bcountry:Country {name: n}) MERGE (a)-[:HAS_BORDER_WITH]-(bcountry))") 

It should look like this:

Screenshot 2022-11-22 at 21.02.12.png

What I get in neo4j:

Screenshot 2022-11-22 at 21.03.00.png

I also tried to do like this, but then I get duplicates of countries:

def create_bordering_country(tx, name, bcountry):
    tx.run("MATCH (a:Country) WHERE a.name = $name "
           "MERGE (a)-[:HAS_BORDER_WITH]-(:Country {name: $bcountry}) RETURN DISTINCT a.name",
           name=name, bcountry=bcountry)

session.execute_write(create_bordering_country, "russia", "China")
    session.execute_write(create_bordering_country, "India", "China")
    session.execute_write(create_bordering_country, "russia", "Kazakhstan")
    session.execute_write(create_bordering_country, "russia", "Lithuania")
    session.execute_write(create_bordering_country, "russia", "Finland")
    session.execute_write(create_bordering_country, "Poland", "Lithuania")
    session.execute_write(create_bordering_country, "China", "Japan")
    session.execute_write(create_bordering_country, "Russia", "Japan")
    session.execute_write(create_bordering_country, "Philipines", "Japan")
    session.execute_write(create_bordering_country, "Philipines", "China")
    session.execute_write(create_bordering_country, "Germany", "Poland")
    session.execute_write(create_bordering_country, "Austria", "Poland")
    session.execute_write(create_bordering_country, "Czechia", "Poland")
    session.execute_write(create_bordering_country, "Czechia", "Austria")
    session.execute_write(create_bordering_country, "Czechia", "Germany")
    session.execute_write(create_bordering_country, "Germany", "Austria") 

1 ACCEPTED SOLUTION

steggy
Neo4j
Neo4j

@laureee777 just two minor issues (one syntax, one semantic).

First: session.execute_write(create_country, "russia","Asia",143,"terrorist state") - should be "Russia"

Second,

def create_bordering_country(tx, name, bcountry):
   tx.run("MERGE (a:Country) WHERE a.name = $name"
   "MERGE (b:Country) WHERE b.name = $bcountry"
   "MERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name")

You really want to MATCH the countries (not MERGE) and also you forgot your parameters. I tried this:

def create_bordering_country(tx, name, bcountry):
    tx.run("MATCH (a:Country {name: $name}), (b:Country {name: $bcountry}) \nMERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name", name=name, bcountry=bcountry)

The whole thing:

from neo4j import GraphDatabase
driver = GraphDatabase.driver("xxxx", auth=("xxxx", "xxxx"))

def create_country(tx, name,continent,population_mln,govrm_system):
    tx.run("CREATE (a:Country {name: $name,continent: $continent,population_mln: $population_mln,govrm_system:$govrm_system})", name=name,continent=continent,population_mln=population_mln,govrm_system=govrm_system)


def create_bordering_country(tx, name, bcountry):
    tx.run("MATCH (a:Country {name: $name}), (b:Country {name: $bcountry}) \nMERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name", name=name, bcountry=bcountry)

def create_organization(tx, name,founded,headquarters):
    tx.run("CREATE (a:Organization {name: $name,founded: $founded,headquarters: $headquarters})", name=name,founded=founded,headquarters=headquarters)

def create_head_of_state(tx, name,term):
    tx.run("CREATE (a:head_of_state {name: $name,term: $term})", name=name,term=term)

with driver.session() as session:
    session.execute_write(create_country, "Russia","Asia",143,"terrorist state")
    session.execute_write(create_country, "India","Asia",1393,"Parliamentary Republic")
    session.execute_write(create_country, "China","Asia",1412,"One-party state")
    session.execute_write(create_country, "Poland","Europe",37,"Parliamentary Republic")
    session.execute_write(create_country, "Kazakhstan","Asia",19,"Presidential system Republic")
    session.execute_write(create_country, "Lithuania","Europe",2.7,"Parliamentary Republic")
    session.execute_write(create_country, "Finland","Europe",5.5,"Parliamentary Republic")
    session.execute_write(create_country, "Philipines","Asia",111,"Parliamentary Republic")
    session.execute_write(create_country, "Japan","Asia",125,"Constitutional Monarchy")
    session.execute_write(create_country, "Germany","Europoe",83,"Parliamentary Republic")
    session.execute_write(create_country, "Czechia","Europoe",10,"Parliamentary Republic")
    session.execute_write(create_country, "Austria","Europoe",9,"Parliamentary Republic")
    session.execute_write(create_head_of_state, "V.Putin",2000)
    session.execute_write(create_head_of_state, "Droupadi Murmu",2022)
    session.execute_write(create_head_of_state, "Xi Jinping",2013)
    session.execute_write(create_head_of_state, "A.Duda",2015)
    session.execute_write(create_head_of_state, "Kassym-Jomart Tokayev",2019)
    session.execute_write(create_head_of_state, "G.Nausėda",2019)
    session.execute_write(create_head_of_state, "Sauli Niinistö",2012)
    session.execute_write(create_head_of_state, "Bongbong Marcos",2022)
    session.execute_write(create_head_of_state, "Fumio Kishida", 2021)
    session.execute_write(create_head_of_state, "Frank-Walter Steinmeier",2017)
    session.execute_write(create_head_of_state, "M.Zeman",2013)
    session.execute_write(create_head_of_state, "Alexander Van der Bellen",2017)
    session.execute_write(create_bordering_country, "Russia", "China")
    session.execute_write(create_bordering_country, "India", "China")
    session.execute_write(create_bordering_country, "Russia", "Kazakhstan")
    session.execute_write(create_bordering_country, "Russia", "Lithuania")
    session.execute_write(create_bordering_country, "Russia", "Finland")
    session.execute_write(create_bordering_country, "Poland", "Lithuania")
    session.execute_write(create_bordering_country, "China", "Japan")
    session.execute_write(create_bordering_country, "Russia", "Japan")
    session.execute_write(create_bordering_country, "Philipines", "Japan")
    session.execute_write(create_bordering_country, "Philipines", "China")
    session.execute_write(create_bordering_country, "Germany", "Poland")
    session.execute_write(create_bordering_country, "Austria", "Poland")
    session.execute_write(create_bordering_country, "Czechia", "Poland")
    session.execute_write(create_bordering_country, "Czechia", "Austria")
    session.execute_write(create_bordering_country, "Czechia", "Germany")
    session.execute_write(create_bordering_country, "Germany", "Austria")
    session.execute_write(create_organization, "NATO",1949,"Belgium")
    session.execute_write(create_organization, "APEC",1989,"Singapore") #Asia-Pacific Economic Cooperation
    session.execute_write(create_organization, "COE",1949,"France") #Council of Europe
    session.execute_write(create_organization, "EU",1993,"Belgium") #European Union
    session.execute_write(create_organization, "UN",1945,"US") #United Nations
    session.execute_write(create_organization, "World Bank",1944,"US")

driver.close()

View solution in original post

6 REPLIES 6

glilienfield
Ninja
Ninja

1) I don’t see the variable ‘a’ defined in the following method in your first block of code. It’s used in your forEach loop.

create_bordering_country


2) I believe you are getting duplicate Country nodes because of the following block of code. Refactor the code to match on the Country node and then use the binding variable in the merge statement, so you have something like ‘MERGE (a)-[:HAS_BORDER_WITH]-(b)’, where ‘b’ is the binding variable from the new match.

MERGE (a)-[:HAS_BORDER_WITH]-(:Country {name: $bcountry})

I have tried similar as You recommend, but I get an error. Maybe You know what is wrong:

def create_country(tx, name,continent,population_mln,govrm_system):
tx.run("CREATE (a:Country {name: $name,continent: $continent,population_mln: $population_mln,govrm_system:$govrm_system})", name=name,continent=continent,population_mln=population_mln,govrm_system=govrm_system)


def create_bordering_country(tx, name, bcountry):
tx.run("MERGE (a:Country) WHERE a.name = $name"
"MERGE (b:Country) WHERE b.name = $bcountry"
"MERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name")

def create_organization(tx, name,founded,headquarters):
tx.run("CREATE (a:Organization {name: $name,founded: $founded,headquarters: $headquarters})", name=name,founded=founded,headquarters=headquarters)

def create_head_of_state(tx, name,term):
tx.run("CREATE (a:head_of_state {name: $name,term: $term})", name=name,term=term)

with driver.session() as session:
session.execute_write(create_country, "russia","Asia",143,"terrorist state")
session.execute_write(create_country, "India","Asia",1393,"Parliamentary Republic")
session.execute_write(create_country, "China","Asia",1412,"One-party state")
session.execute_write(create_country, "Poland","Europe",37,"Parliamentary Republic")
session.execute_write(create_country, "Kazakhstan","Asia",19,"Presidential system Republic")
session.execute_write(create_country, "Lithuania","Europe",2.7,"Parliamentary Republic")
session.execute_write(create_country, "Finland","Europe",5.5,"Parliamentary Republic")
session.execute_write(create_country, "Philipines","Asia",111,"Parliamentary Republic")
session.execute_write(create_country, "Japan","Asia",125,"Constitutional Monarchy")
session.execute_write(create_country, "Germany","Europoe",83,"Parliamentary Republic")
session.execute_write(create_country, "Czechia","Europoe",10,"Parliamentary Republic")
session.execute_write(create_country, "Austria","Europoe",9,"Parliamentary Republic")
session.execute_write(create_head_of_state, "V.Putin",2000)
session.execute_write(create_head_of_state, "Droupadi Murmu",2022)
session.execute_write(create_head_of_state, "Xi Jinping",2013)
session.execute_write(create_head_of_state, "A.Duda",2015)
session.execute_write(create_head_of_state, "Kassym-Jomart Tokayev",2019)
session.execute_write(create_head_of_state, "G.Nausėda",2019)
session.execute_write(create_head_of_state, "Sauli Niinistö",2012)
session.execute_write(create_head_of_state, "Bongbong Marcos",2022)
session.execute_write(create_head_of_state, "Fumio Kishida", 2021)
session.execute_write(create_head_of_state, "Frank-Walter Steinmeier",2017)
session.execute_write(create_head_of_state, "M.Zeman",2013)
session.execute_write(create_head_of_state, "Alexander Van der Bellen",2017)
session.execute_write(create_bordering_country, "Russia", "China")
session.execute_write(create_bordering_country, "India", "China")
session.execute_write(create_bordering_country, "Russia", "Kazakhstan")
session.execute_write(create_bordering_country, "Russia", "Lithuania")
session.execute_write(create_bordering_country, "Russia", "Finland")
session.execute_write(create_bordering_country, "Poland", "Lithuania")
session.execute_write(create_bordering_country, "China", "Japan")
session.execute_write(create_bordering_country, "Russia", "Japan")
session.execute_write(create_bordering_country, "Philipines", "Japan")
session.execute_write(create_bordering_country, "Philipines", "China")
session.execute_write(create_bordering_country, "Germany", "Poland")
session.execute_write(create_bordering_country, "Austria", "Poland")
session.execute_write(create_bordering_country, "Czechia", "Poland")
session.execute_write(create_bordering_country, "Czechia", "Austria")
session.execute_write(create_bordering_country, "Czechia", "Germany")
session.execute_write(create_bordering_country, "Germany", "Austria")
session.execute_write(create_organization, "NATO",1949,"Belgium")
session.execute_write(create_organization, "APEC",1989,"Singapore") #Asia-Pacific Economic Cooperation
session.execute_write(create_organization, "COE",1949,"France") #Council of Europe
session.execute_write(create_organization, "EU",1993,"Belgium") #European Union
session.execute_write(create_organization, "UN",1945,"US") #United Nations
session.execute_write(create_organization, "World Bank",1944,"US")


driver.close()

Error I get:

CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: Invalid input 'WHERE': expected
  "("
  "CALL"
  "CREATE"
  "DELETE"
  "DETACH"
  "FOREACH"
  "LOAD"
  "MATCH"
  "MERGE"
  "ON"
  "OPTIONAL"
  "REMOVE"
  "RETURN"
  "SET"
  "UNION"
  "UNWIND"
  "USE"
  "WITH"
  <EOF> (line 1, column 19 (offset: 18))
"MERGE (a:Country) WHERE a.name = $nameMERGE (a:Country) WHERE a.name = $bcountryMERGE (a)-[:HAS_BORDER_WITH]-(a) RETURN a.name"
                   ^}

I tried to write silimar code as you recommended, but I got an error, maybe you know what is wrong and how to fix it?

My code:

def create_country(tx, name,continent,population_mln,govrm_system):
tx.run("CREATE (a:Country {name: $name,continent: $continent,population_mln: $population_mln,govrm_system:$govrm_system})", name=name,continent=continent,population_mln=population_mln,govrm_system=govrm_system)


def create_bordering_country(tx, name, bcountry):
tx.run("MERGE (a:Country) WHERE a.name = $name"
"MERGE (b:Country) WHERE b.name = $bcountry"
"MERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name")

def create_organization(tx, name,founded,headquarters):
tx.run("CREATE (a:Organization {name: $name,founded: $founded,headquarters: $headquarters})", name=name,founded=founded,headquarters=headquarters)

def create_head_of_state(tx, name,term):
tx.run("CREATE (a:head_of_state {name: $name,term: $term})", name=name,term=term)

with driver.session() as session:
session.execute_write(create_country, "russia","Asia",143,"terrorist state")
session.execute_write(create_country, "India","Asia",1393,"Parliamentary Republic")
session.execute_write(create_country, "China","Asia",1412,"One-party state")
session.execute_write(create_country, "Poland","Europe",37,"Parliamentary Republic")
session.execute_write(create_country, "Kazakhstan","Asia",19,"Presidential system Republic")
session.execute_write(create_country, "Lithuania","Europe",2.7,"Parliamentary Republic")
session.execute_write(create_country, "Finland","Europe",5.5,"Parliamentary Republic")
session.execute_write(create_country, "Philipines","Asia",111,"Parliamentary Republic")
session.execute_write(create_country, "Japan","Asia",125,"Constitutional Monarchy")
session.execute_write(create_country, "Germany","Europoe",83,"Parliamentary Republic")
session.execute_write(create_country, "Czechia","Europoe",10,"Parliamentary Republic")
session.execute_write(create_country, "Austria","Europoe",9,"Parliamentary Republic")
session.execute_write(create_head_of_state, "V.Putin",2000)
session.execute_write(create_head_of_state, "Droupadi Murmu",2022)
session.execute_write(create_head_of_state, "Xi Jinping",2013)
session.execute_write(create_head_of_state, "A.Duda",2015)
session.execute_write(create_head_of_state, "Kassym-Jomart Tokayev",2019)
session.execute_write(create_head_of_state, "G.Nausėda",2019)
session.execute_write(create_head_of_state, "Sauli Niinistö",2012)
session.execute_write(create_head_of_state, "Bongbong Marcos",2022)
session.execute_write(create_head_of_state, "Fumio Kishida", 2021)
session.execute_write(create_head_of_state, "Frank-Walter Steinmeier",2017)
session.execute_write(create_head_of_state, "M.Zeman",2013)
session.execute_write(create_head_of_state, "Alexander Van der Bellen",2017)
session.execute_write(create_bordering_country, "Russia", "China")
session.execute_write(create_bordering_country, "India", "China")
session.execute_write(create_bordering_country, "Russia", "Kazakhstan")
session.execute_write(create_bordering_country, "Russia", "Lithuania")
session.execute_write(create_bordering_country, "Russia", "Finland")
session.execute_write(create_bordering_country, "Poland", "Lithuania")
session.execute_write(create_bordering_country, "China", "Japan")
session.execute_write(create_bordering_country, "Russia", "Japan")
session.execute_write(create_bordering_country, "Philipines", "Japan")
session.execute_write(create_bordering_country, "Philipines", "China")
session.execute_write(create_bordering_country, "Germany", "Poland")
session.execute_write(create_bordering_country, "Austria", "Poland")
session.execute_write(create_bordering_country, "Czechia", "Poland")
session.execute_write(create_bordering_country, "Czechia", "Austria")
session.execute_write(create_bordering_country, "Czechia", "Germany")
session.execute_write(create_bordering_country, "Germany", "Austria")
session.execute_write(create_organization, "NATO",1949,"Belgium")
session.execute_write(create_organization, "APEC",1989,"Singapore") #Asia-Pacific Economic Cooperation
session.execute_write(create_organization, "COE",1949,"France") #Council of Europe
session.execute_write(create_organization, "EU",1993,"Belgium") #European Union
session.execute_write(create_organization, "UN",1945,"US") #United Nations
session.execute_write(create_organization, "World Bank",1944,"US")


driver.close()

Error I get:

CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: Invalid input 'WHERE': expected
  "("
  "CALL"
  "CREATE"
  "DELETE"
  "DETACH"
  "FOREACH"
  "LOAD"
  "MATCH"
  "MERGE"
  "ON"
  "OPTIONAL"
  "REMOVE"
  "RETURN"
  "SET"
  "UNION"
  "UNWIND"
  "USE"
  "WITH"
  <EOF> (line 1, column 19 (offset: 18))
"MERGE (a:Country) WHERE a.name = $nameMERGE (a:Country) WHERE a.name = $bcountryMERGE (a)-[:HAS_BORDER_WITH]-(a) RETURN a.name"
                   ^}

If you look at the error, you see that the cypher is missing a space before the second and third merge clause. As such the statement cannot be parsed. Also you don’t pass the values for name and bCountry in your ‘run’ method. Finally, you have the cypher as three strings, back to back. This code is in your create_boarding_country method.

steggy
Neo4j
Neo4j

@laureee777 just two minor issues (one syntax, one semantic).

First: session.execute_write(create_country, "russia","Asia",143,"terrorist state") - should be "Russia"

Second,

def create_bordering_country(tx, name, bcountry):
   tx.run("MERGE (a:Country) WHERE a.name = $name"
   "MERGE (b:Country) WHERE b.name = $bcountry"
   "MERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name")

You really want to MATCH the countries (not MERGE) and also you forgot your parameters. I tried this:

def create_bordering_country(tx, name, bcountry):
    tx.run("MATCH (a:Country {name: $name}), (b:Country {name: $bcountry}) \nMERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name", name=name, bcountry=bcountry)

The whole thing:

from neo4j import GraphDatabase
driver = GraphDatabase.driver("xxxx", auth=("xxxx", "xxxx"))

def create_country(tx, name,continent,population_mln,govrm_system):
    tx.run("CREATE (a:Country {name: $name,continent: $continent,population_mln: $population_mln,govrm_system:$govrm_system})", name=name,continent=continent,population_mln=population_mln,govrm_system=govrm_system)


def create_bordering_country(tx, name, bcountry):
    tx.run("MATCH (a:Country {name: $name}), (b:Country {name: $bcountry}) \nMERGE (a)-[:HAS_BORDER_WITH]-(b) RETURN a.name", name=name, bcountry=bcountry)

def create_organization(tx, name,founded,headquarters):
    tx.run("CREATE (a:Organization {name: $name,founded: $founded,headquarters: $headquarters})", name=name,founded=founded,headquarters=headquarters)

def create_head_of_state(tx, name,term):
    tx.run("CREATE (a:head_of_state {name: $name,term: $term})", name=name,term=term)

with driver.session() as session:
    session.execute_write(create_country, "Russia","Asia",143,"terrorist state")
    session.execute_write(create_country, "India","Asia",1393,"Parliamentary Republic")
    session.execute_write(create_country, "China","Asia",1412,"One-party state")
    session.execute_write(create_country, "Poland","Europe",37,"Parliamentary Republic")
    session.execute_write(create_country, "Kazakhstan","Asia",19,"Presidential system Republic")
    session.execute_write(create_country, "Lithuania","Europe",2.7,"Parliamentary Republic")
    session.execute_write(create_country, "Finland","Europe",5.5,"Parliamentary Republic")
    session.execute_write(create_country, "Philipines","Asia",111,"Parliamentary Republic")
    session.execute_write(create_country, "Japan","Asia",125,"Constitutional Monarchy")
    session.execute_write(create_country, "Germany","Europoe",83,"Parliamentary Republic")
    session.execute_write(create_country, "Czechia","Europoe",10,"Parliamentary Republic")
    session.execute_write(create_country, "Austria","Europoe",9,"Parliamentary Republic")
    session.execute_write(create_head_of_state, "V.Putin",2000)
    session.execute_write(create_head_of_state, "Droupadi Murmu",2022)
    session.execute_write(create_head_of_state, "Xi Jinping",2013)
    session.execute_write(create_head_of_state, "A.Duda",2015)
    session.execute_write(create_head_of_state, "Kassym-Jomart Tokayev",2019)
    session.execute_write(create_head_of_state, "G.Nausėda",2019)
    session.execute_write(create_head_of_state, "Sauli Niinistö",2012)
    session.execute_write(create_head_of_state, "Bongbong Marcos",2022)
    session.execute_write(create_head_of_state, "Fumio Kishida", 2021)
    session.execute_write(create_head_of_state, "Frank-Walter Steinmeier",2017)
    session.execute_write(create_head_of_state, "M.Zeman",2013)
    session.execute_write(create_head_of_state, "Alexander Van der Bellen",2017)
    session.execute_write(create_bordering_country, "Russia", "China")
    session.execute_write(create_bordering_country, "India", "China")
    session.execute_write(create_bordering_country, "Russia", "Kazakhstan")
    session.execute_write(create_bordering_country, "Russia", "Lithuania")
    session.execute_write(create_bordering_country, "Russia", "Finland")
    session.execute_write(create_bordering_country, "Poland", "Lithuania")
    session.execute_write(create_bordering_country, "China", "Japan")
    session.execute_write(create_bordering_country, "Russia", "Japan")
    session.execute_write(create_bordering_country, "Philipines", "Japan")
    session.execute_write(create_bordering_country, "Philipines", "China")
    session.execute_write(create_bordering_country, "Germany", "Poland")
    session.execute_write(create_bordering_country, "Austria", "Poland")
    session.execute_write(create_bordering_country, "Czechia", "Poland")
    session.execute_write(create_bordering_country, "Czechia", "Austria")
    session.execute_write(create_bordering_country, "Czechia", "Germany")
    session.execute_write(create_bordering_country, "Germany", "Austria")
    session.execute_write(create_organization, "NATO",1949,"Belgium")
    session.execute_write(create_organization, "APEC",1989,"Singapore") #Asia-Pacific Economic Cooperation
    session.execute_write(create_organization, "COE",1949,"France") #Council of Europe
    session.execute_write(create_organization, "EU",1993,"Belgium") #European Union
    session.execute_write(create_organization, "UN",1945,"US") #United Nations
    session.execute_write(create_organization, "World Bank",1944,"US")

driver.close()

Thank You! It is working.