2016-07-06 46 views
0

一直在嘗試使用python運行查詢neo4j數據庫。該代碼適用於最簡單的查詢,但不適用於所有情況。我沒有得到任何異常,並不瞭解日誌文件的根本原因。無法在python上運行neo4j的密碼查詢

我的代碼看起來是這樣的..

from neo4j.v1 import GraphDatabase, basic_auth 

graph_url = "bolt://localhost:7687" 
graph_username = "neo4j" 
graph_password = "neo4j" 

driver =GraphDatabase.driver(graph_url, auth=basic_auth(graph_username, graph_password)) 
session = driver.session() 
query_simple="Create (enitity:n{name : 'john doe'})" 
session.run(query_simple) 

query = "LOAD CSV WITH HEADERS FROM 'http://data.neo4j.com/northwind/products.csv' AS row CREATE (n:Product) SET n = row n.unitPrice = toFloat(row.unitPrice), n.unitsInStock = toInt(row.unitsInStock), n.unitsOnOrder = toInt(row.unitsOnOrder), n.reorderLevel = toInt(row.reorderLevel), n.discontinued = (row.discontinued <> '0')" 
session.run(query) 

簡單的查詢運行正常,但其他查詢犯規運行。它是一種簡單的查詢這在調試日誌文件的Neo4j的GUI作品在我的本地主機

上我得到這兩種類型的錯誤日誌:

2016年7月6日22:14:27.062 + 0000 ERROR [onbvtBoltProtocolV1]無法寫入響應於駕駛員

顯示java.lang.NullPointerException在 org.neo4j.bolt.v1.transport.ChunkedOutput.ensure(ChunkedOutput.java:156) 在 org.neo4j。 bolt.v1.transport.ChunkedOutput.writeShort(ChunkedOutput.java:90) at org.neo4j.bolt.v1.packstream.PackStream $ Packer.packStructHeader(PackStream.java:304) 在 org.neo4j.bolt.v1.messaging.PackStreamMessageFormatV1 $ Writer.handleFailureMessage(PackStreamMessageFormatV1.java:154) 在 org.neo4j.bolt.v1.messaging.msgprocess.MessageProcessingCallback.publishError(MessageProcessingCallback.java:48) 在 org.neo4j.bolt.v1.messaging.msgprocess.MessageProcessingCallback.completed(MessageProcessingCallback.java:98) 在 org.neo4j.bolt.v1.messaging.msgprocess.MessageProcessingCallback.completed(MessageProcessingCallback.java:31) 在 org.neo4j.bolt.v1.runtime.internal.SessionStateMachine.after(SessionStateMachine.java:823) 在 org.neo4j.bolt.v1.runtime.internal.SessionStateMachine.run(SessionStateMachine.java:655) 在 org.neo4j.bolt.v1.runtime.internal.concurrent.SessionWorkerFacade.lambda $運行$ 3(SessionWorkerFacade。 java:68) at org.neo4j.bolt.v1.runtime.internal.concurrent.SessionWorker.execute(SessionWorker.java:116) at org.neo4j.bolt.v1.runtime.internal.concurrent.SessionWorker。運行(SessionWorker.java:77)在java.lang.Thread.run(Thread.java:745)

2016-07-06 20:52:20.588 + 0000錯誤[onbtSocketTransportHandler] 處理客戶端連接時發生致命錯誤:連接 由對等方重置由同位體重置的連接java.io.IOException:連接 由peer在太陽.nio.ch.FileDispatcherImpl.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)at sun.nio.ch.IOUtil.read(IOUtil.java:192)at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java: 311) at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBu (NioSocketChannel。)。的java:242) 在 io.netty.channel.nio.AbstractNioByteChannel $ NioByteUnsafe.read(AbstractNioByteChannel.java:119) 在 io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) 在 io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) 在 io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) 在io.netty.channel.nio。 NioEventLoop.run(NioEventLoop.java:354)在 io.netty.util.concurrent.SingleThreadEventExecutor $ 2.run(SingleThreadEventExecutor.java:111) 在java.lang.Thread.run(Thread.java:745)

我使用的Neo4j的社區版我的系統上,Python版本提前:) 3.5

感謝

+0

通過發送數據作爲參數在當時能夠工作 – mayank

回答

0

你已經注意到該文件conf/neo4j.conf在下面的部分? https://neo4j.com/developer/kb/explanation-of-error-load-csv-error-of-couldnt-load-the-external-resource/

你也可以通過下載CSV文件,試圖將其保存到import目錄:

# Determines if Cypher will allow using file URLs when loading data using 
# `LOAD CSV`. Setting this value to `false` will cause Neo4j to fail `LOAD CSV` 
# clauses that load data from the file system. 
#dbms.security.allow_csv_import_from_file_urls=true 

但是(在取消對線之上,並重新啓動的Neo4j後),你可能會與另一個錯誤什麼的解釋然後使用:

LOAD CSV WITH HEADERS FROM 'file:///products.csv' AS row ...