Database read node and Neo4j

Hi

This is tantilisingly close to working with Neo4j, but just a step away!

We have installed the latest jdbc drivers from Neo4j, https://github.com/neo4j-contrib/neo4j-jdbc/releases/tag/3.0, and have used it to connect an instance of the graph database. This worked. We then try to pull some data out in a database reader node. The cypher query is

Match (p:product) return p

which should return all the nodes which are products.

it does return, but only the first node makes it to the output table. It returns as a string that can be turned into a json type. 

{"status":"YES","ID":"cornflakes","rules":"before 9am","uuid":"d4a00670-9a05-11e6-a0af-00155d68022d"}

 

We have a feeling it may be returning as separate result sets, and so the others may be dropped.

When we put more conditions on the query, we get an error 

ERROR Database Reader      4:55       Execute failed: Encountered duplicate row ID  "Row0" at row number 2

Can't really see what is creating it.

Has anyone any experience of what can be done? It would be great if the database nodes can work for Neo4j.

David

 

Hi David,

it seems the JDBC driver does not return a unique row number in the ResultSet.getRow() method which causes KNIME to fail. It would already solve the problem if the driver would simply throw an SQLFeatureNotSupportedException which isn't the case. The Database Connection Table Reader node has an option to ignore the database row number and use an internal counter instead. We plan to add the same option to the Database Reader as well. We might be able to add the option to the node with the December release but I can't promiss it. Until then you will need to use an external tool to read the data into a file which you can then load into KNIME with the CSV or File Reader for example.

Bye

Tobias

 

That would be great, the database nodes are very convenient for constructing the queries, we are currenly using the rest nodes, and have also been trying python via bolt. However, they are much trickier to write a query.

Many thanks for your response,

David

 

Hi Tobias,

I'm facing the same problem with SF-Connection.

Now the December-Release 3.3 is out, I miss the option in the "Database Reader" node.
Do you know when it will be added?

Best

Bernd
 

We have just released a preview of the new database framework which is available via the labs update site. This comes with a new DB Query Reader node which no longer uses the db row id and thus should solve your problem. Give it a try and let us know if you encounter any problems.
Bye
Tobias

1 Like

I could successfully connect to Neo4J and run Cypher queries against it, using py2neo on python nodes. If it helps, I can provide you with sample code.

1 Like

Thanks, that would be nice.

have you tried similar things with triple stores, like GraphDB or Stardog?

Here’s the code using py2neo:

from py2neo import Graph, types
from pandas import DataFrame

graph = Graph(host="x.x.x.x",
                     http_port=7474,
                     user="xxx",
                     password="xxx",
                     bolt=False)

# Your query here
# Notice that returned values have basic KNIME types (eg. String, Int and so on)
query = "match (h:History)-[rt]-(t:Concept)-[rc]-(c:Concept) where toString(h.id) =~ '20180624114754.*' return h.id, h.fsn, h.daydate"

result = graph.run(query).data()

df = DataFrame(result)

output_table = df.copy()

The example above uses py2neo, but the same idea works with Neo4J Python driver.

GraphDB or Stardog? No, haven’t tried those.

Good luck!

1 Like

Many thanks, appreciate your help.

Best

David

I got some basic Neo4J functionality working recently using the “old” database connector nodes and JDBC connection, but wondered if anyone has managed to use the OrientDB JDBC driver in KNIME - I tried, but cannot open a connection to a running OrientDB server. I also wondered if there are any plans for graph database integration either via specific nodes for OrientDB or Neo4J or possibly using tinkerpop?

Steve

Hello @s.roughley please check out our new Neo4j extension for Knime 4.2.
https://hub.knime.com/redfield/extensions/se.redfield.knime.neo4jextension.feature/latest

3 Likes