how to export neo4j data of database A to database B? - neo4j

I have two cases:
case 1:export a part of data in neo4j database A to database B,like data of Label "Person" in database A ,I wanna export "Person" data from A to B
case 2: export whole data from A to B
so how to deal with these two cases? thanks

APOC allows to export the full graph or subgraphs into a cypher file consisting of create statements, see https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_export_to_cypher_script for details.
The other option would be access the other database via the neo4j jdbc driver and use apoc.load.jdbc to retrieve data from there.

Related

Vote How to view Cypher queries back for a database

I have used Neo4J ETL tool and create a Neo4J database from Postgres SQL and this looks perfect. I can see all nodes, relationships, data, etc.
Now I want to see all the database file, the Cypher queries for all node and relationship creation along with different constraint applied to this database.
How can I view this? I can see database folder is empty for Neo4J home,
C:\Users\I\.Neo4jDesktop\relate-data\dbmss\dbms-9cf178b6-f37f-4139-8b80-dadf0fa03866\data\databases
2nd question, can I generates graphql schema from the Cypher script using any tool or some mean?
Thanks!
I think below codes can help you to get meta-data and schema
// Show meta-graph
CALL db.schema.visualization()
// List node labels
CALL db.labels()
// List relationship types
CALL db.relationshipTypes()

Neo4j APOC export/import with primary keys instead of internal ids

I am trying to import multiple CSVs, exported from multiple different Neo4j databases with APOC's export, into one big database. Some of the nodes are shared.
There is a problem that relationships in the CSV use the Neo4j's internal IDs for the _start and _end, instead of the nodes' "primary key" -- is the #Index with primary = true (same as #Id) a thing of the Neo4j or the Neo4j's Java OGM?. This is bad because these multiple exports could (and will) have same internal IDs for different nodes and the merged graph will be a mess. The same applies for nodes, I want to merge them based on the primary key during the import instead of creating duplicates.
Is there a way to export a Neo4j database with APOC in a way that it relies on primary keys instead of internal IDs? I need a CSV or JSON file, no CQL. Or is there another way of exporting a Neo4j database in a way that I can import multiple exports and they will merge seamlessly? ...something different than writing my CSV exporter and imported, this will be the very last option.

Export Neo4j db creation statements

Such as the example movies database
Is it possible to extract the single statement that creates the current database with all it's properties, relations and nodes?
You can install APOC procedures and use apoc.export.cypher.all. From the docs:
apoc.export.cypher.all(file,config) - exports whole database incl.
indexes as cypher statements to the provided file

Migrating data from MySQL(rdbms) to Neo4j database

I wanted to migrate data from MySQL to neo4j database. So how can i start with. I do not want to use any ETL tools like Talend. Directly if i want to migrate the data from any of the relational database to neo4j , how can i do it? Do i need to use any JDBC drivers?
Suppose say in my MySQL database, i have a table called emp and data as below:
companyname, domain,head, manager, employee
abc ,service, Adam, Taylor, Smith
abc ,service, John, sufi, sham
abc , industrial,George, Ralf, maxin
abc,industrial,George,susen,leena
xyz, service,josaf,Rihan, dardy
So if i want to migrate this data into neo4j, how can i do it? How data will be seen in neo4j? Do i need to explicitly define the nodes and relationships to migrate the data ? If yes, how this can be done?
Thanks,
Shree
The first thing to do would be to model your graph irrespective of where the data is coming from. I don't know your use case but I imagine you'd have nodes for company, domain, person and relations between persons and companies or persons and persons (manager etc.)
Once you've got your graph model in place, then you can simply read from MySQL, transform the data to represent your nodes/relations and write it to Neo4j.
Have a look at http://neo4j.com/blog/data-migration-between-mysql-and-neo4j/ for an example on how this worked for my use case.

neo4j : Is there any such command is neo4j like 'CREATE DATABASE'

I want to create a new Database in neo4j using Cypher as I am not a Java (or Programming language) guy but a Database person ....Could I create a neo4j database using Cypher before creating nodes and relationships ...I am using ne04j community console and would like to create a new database
Thanks !
There is only one database.
You can clean out your current data by either stopping the server and removing the database on disk /path/to/neo4j/data/graph.db and starting it again.
Or by executing a Cypher statement like:
MATCH (n)
OPTIONAL MATCH (n)-[r]->()
DELETE n,r
You dont need to create a new database as(neo4j folder)\data\graph.db is the default path for the database.Neo4j is different from the relational databases.Folder it self is a database.In a graph database you have to create three things: nodes,relationships and properties.
If you want to change the database path you can change the path in conf/neo4j-server.properties.
You can also refer below link:
How to delete/create databases in Neo4j?

Resources