Connecting to other databases
APOC provides ways to integrate with various databases to read or modify data. We will take a look at each of these methods to see how we can interact with other databases from Cypher:
- JDBC: To connect to JDBC-compliant data using a JDBC driver, we need to make sure to add the required JARs to the
plugins
directory. Once you have added the JARs to theplugins
directory, restart the server instance.
To make sure the jdbc
driver is loaded, we need to execute the load driver method first as shown here:
CALL apoc.load.driver("com.mysql.test.Driver")
Once the driver is loaded, we can query the data using the load.jdbc
method. We will take a look at an example query here:
WITH "jdbc:mysql://localhost:3306/mydb?user=root" as url CALL apoc.load.jdbc(url,"person") YIELD row RETURN row
This query returns each row as a map from the person table in the mydb
database. You can take this row and add it to a graph...