Graph transfer

Hello
is there any way to transfer the content from one graphics database to another graphics database so that the two contents are together only in one database?

By "together in one database", do you mean one neo4j system with two graphs in it? Or do you mean 1 neo4j system with 1 graph, which is the "merged" version of both of the two inputs?

I have 1 Neo4j system with 2 bank, each has 1 graph and I want to put these graphs in 1 database of the same Neo4j system.

With APOC you could create an export in Cypher format of one Graph and use the resulting Cypher code to import it in the other Graph. That way you essentially would merge both graphs into one.

how do I create this export in cypher?

See https://neo4j.com/docs/labs/apoc/current/export/cypher/ for the gory details.

In short:

  1. add these lines to your neo4j.conf
apoc.export.file.enabled=true
apoc.import.file.enabled=true
  1. call the export function
        CALL apoc.export.cypher.query(
            "MATCH p=(a:MyActivity {{uuid:'{activity_uuid}'}})-[:BLOCK]-() 
            RETURN p","filename",{format:'plain',cypherFormat:'create'}
        )

The code above is from a live project I am working on. Replace the MATCH with the one which works for your model. The "filename" is the file to export to, this will be created in your "import" folder in your Neo4J install.

Typical this is something like /var/lib/neo4j/import but you can ask the server for its location by:

CALL dbms.listConfig() yield name,value where name='dbms.directories.import' return value

Hope this helps!
Paul

1 Like

Hi Paulo
one more doubt. I managed to create the export file and now how do I import and extract the graph in the other database?
I created the file export.cypher
thank you very much for your help

Ah yes, importing it again is rather useful too :slight_smile:

The way I do it is again via APOC with a call like this:

CALL apoc.cypher.runFile('filename) yield row, result"

Where filename is the name of your exported file. The Neo4J server assumes it being in the import folder if I remember correctly.

I choose the APOC route because it is some functionality I need to use in the user-interface of the application I am working on.

Note though, the file created on export is just a Cypher file so if this is a one-off thing you might use the cypher-shell instead, see cypher-shell --help for details but the gist is:

cat some-cypher.txt | cypher-shell

Hope this helps,
Paul

2 Likes

thank you very much, Paulo
worked correctly. Hugs!!

1 Like