neo4j,nodejs,会话过期错误,如何解决? [英] neo4j, nodejs, session expire error, how to fix it?

查看:164
本文介绍了neo4j,nodejs,会话过期错误,如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在后端使用neo4j.首先,我想将csv导入neo4j. (首先尝试查看csv文件有多少行) 但是有问题,代码如下

I was trying to use neo4j at backend. First I want to import csv to neo4j. (first tried to see how many lines csv file has) But having problem, the code is following

var neo4j = require('neo4j-driver').v1;
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "neo4j"));

function createGraphDataBase(csvfilepath) 
{
  var session = driver.session();
  return session
     .run( 'LOAD CSV FROM {csvfilepath} AS line RETURN count(*)', 
         {csvfilepath}
  )
  .then(result => {
     session.close();
     console.log(' %d lines in csv.file', result);
     return result;
  })
  .catch(error => {
    session.close();
    console.log(error);
    return error;
  });
}

"csvfilepath"是csv文件的路径,如下所示.

the "csvfilepath" is the path of csv file, it is as follows.

'/用户/.../文档/项目/.../test/spots.csv'; 给出这样的路径有什么问题吗?

'/Users/.../Documents/Project/.../test/spots.csv'; is there something wrong with giving path like this?

我正在其他模块上调用该函数

I am calling that function on other module as

 var api = require('./neo4j.js');    
 const csvFile = path.join(__dirname,csvFileName); 
 api.createGraphDataBase(csvFile);

我有错误

错误:服务器已关闭连接 ....

Error: Connection was closed by server ....

我是新手,请帮忙!

推荐答案

您在LOAD CSV子句中指定的URL必须是合法URL.

The URL that you specify in a LOAD CSV clause must be a legal URL.

本指南所述:

确保使用正确的URL,尤其是esp.文件网址.+在OSX和Unix上使用 file:///path/to/data.csv,在Windows上,请使用 文件:c:/path/to/data.csv

Make sure to use the right URLs esp. file URLs.+ On OSX and Unix use file:///path/to/data.csv, on Windows, please use file:c:/path/to/data.csv

在您的情况下,csvfilepath需要为本地文件指定file:///协议(因为您似乎正在OSX上运行).根据您的示例,该值应如下所示:

In your case, csvfilepath needs to specify the file:/// protocol (since you seem to be running on OSX) for a local file. Based on your example, the value should be something like this:

'file:///Users/.../Documents/Project/.../test/spots.csv'

这篇关于neo4j,nodejs,会话过期错误,如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆