cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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?

1 ACCEPTED SOLUTION

Ah yes, importing it again is rather useful too

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

View solution in original post

11 REPLIES 11

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

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

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

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

I've added the apoc.import.file.enabled=true in the neo4j.conf file

I've exported the entire graph with

CALL apoc.export.csv.all("filename.csv", {})

I've run the runfile-cypher

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

I still get this error

What can be done as to export a graph and import it again

Did you restart the server after the configuration change?

That did the trick