# Call the Neo DB connection
con <- neo4j_api$new( url = "http://localhost:7474", user = "neo4j", password = "123456" )
# Ping to ensure it's live
con$ping()
## [1] 200
## No data returned.
## list()
## attr(,"class")
## [1] "neo" "neo" "list"
on_load_query <- 'CREATE (n:Movie) SET n = row,
n.tableId = toInteger(row.tableId),
n.movieId = toInteger(row.movieId),
n.title = toString(row.title),
n.genres = toString(row.genres);'
load_csv(url = "https://raw.githubusercontent.com/kelloggjohnd/DATA607/master/movies.csv",
con = con, header = TRUE, periodic_commit = 50,
as = "row", on_load = on_load_query)
## No data returned.
## # A tibble: 12 x 2
## type value
## <chr> <dbl>
## 1 contains_updates 1
## 2 nodes_created 9741
## 3 nodes_deleted 0
## 4 properties_set 68187
## 5 relationships_created 0
## 6 relationship_deleted 0
## 7 labels_added 9741
## 8 labels_removed 0
## 9 indexes_added 0
## 10 indexes_removed 0
## 11 constraints_added 0
## 12 constraints_removed 0
## # A tibble: 1 x 1
## labels
## <chr>
## 1 Movie
# This is code I pulled from the interwebs and was playing with but never got it to work. I will keep trying to get it to work as this should pull the table or tibble stright from R, create the load file, then load into the DB.
cypher_query_movies <- " "
for(i in 1:nrow(movies)) {
cypher_query_movies <- paste(cypher_query_movies, "CREATE", vec_to_cypher(movies[i, ], "Movie"), " ")
}
call_neo4j(paste(cypher_query_movies,";"), con)
call_neo4j(cypher_query_movies, con)