Skip to content

Nodes not printing, error: line 1:100 missing '::path' at '<EOF>' #13

@afidegnum

Description

@afidegnum

apache-age-python returns an error over result formatting.
from the AGEviewerer, this query successfully prints the results as right-left nodes containing the list of the right nodes as shown below:

          SELECT * from cypher('text_test', $$
          MATCH (V:node)-[connect]->(V2:node)
			WITH V as parent, COLLECT(V2) as children
          RETURN parent, children
$$) as (parent agtype, children agtype);

and the result below:

{"id":844424930131987,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"second\", \"class\": \"below\"}"}}	[{"id":844424930131988,"label":"node","properties":{"tag":"div","attrib":"{\"class\": \"inner\"}"}}]

{"id":844424930131973,"label":"node","properties":{"tag":"body","attrib":"null"}}	
[{"id":844424930131987,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"second\", \"class\": \"below\"}"}},{"id":844424930131978,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"idone\", \"class\": \"classone\"}"}},{"id":844424930131974,"label":"node","properties":{"tag":"ul","attrib":"{\"class\": \"menu\"}"}}]

{"id":844424930131970,"label":"node","properties":{"tag":"head","attrib":"null"}}	
[{"id":844424930131972,"label":"node","properties":{"tag":"title","attrib":"null"}},
{"id":844424930131971,"label":"node","properties":{"tag":"meta","attrib":"{\"charset\": \"UTF-8\"}"}}]

{"id":844424930131985,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"innertwo\"}"}}	[{"id":844424930131986,"label":"node","properties":{"tag":"h2","attrib":"null"}}]

{"id":844424930131978,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"idone\", \"class\": \"classone\"}"}}
	
[{"id":844424930131985,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"innertwo\"}"}},{"id":844424930131983,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"innerone\"}"}},{"id":844424930131979,"label":"node","properties":{"tag":"ul","attrib":"{\"class\": \"listing\"}"}}]

{"id":844424930131974,"label":"node","properties":{"tag":"ul","attrib":"{\"class\": \"menu\"}"}}
	[{"id":844424930131977,"label":"node","properties":{"tag":"div","attrib":"{\"class\": \"itm\"}"}},{"id":844424930131976,"label":"node","properties":{"tag":"div","attrib":"{\"class\": \"itm\"}"}},{"id":844424930131975,"label":"node","properties":{"tag":"div","attrib":"{\"class\": \"itm\"}"}}]

{"id":844424930131988,"label":"node","properties":{"tag":"div","attrib":"{\"class\": \"inner\"}"}}	
[{"id":844424930131991,"label":"node","properties":{"tag":"h2","attrib":"null"}},{"id":844424930131990,"label":"node","properties":{"tag":"h1","attrib":"null"}},{"id":844424930131989,"label":"node","properties":{"tag":"h1","attrib":"null"}}]

{"id":844424930131983,"label":"node","properties":{"tag":"div","attrib":"{\"id\": \"innerone\"}"}}	[{"id":844424930131984,"label":"node","properties":{"tag":"h1","attrib":"null"}}]

{"id":844424930131979,"label":"node","properties":{"tag":"ul","attrib":"{\"class\": \"listing\"}"}}	[{"id":844424930131982,"label":"node","properties":{"tag":"li","attrib":"{\"class\": \"item3\"}"}},
{"id":844424930131981,"label":"node","properties":{"tag":"li","attrib":"{\"class\": \"item2\"}"}},{"id":844424930131980,"label":"node","properties":{"tag":"li","attrib":"{\"class\": \"item1\"}"}}]

{"id":844424930131969,"label":"node","properties":{"tag":"html","attrib":"{\"lang\": \"en\"}"}}	[{"id":844424930131973,"label":"node","properties":{"tag":"body","attrib":"null"}},{"id":844424930131970,"label":"node","properties":{"tag":"head","attrib":"null"}}]

while using the same procedure on apache-python-age, here is the resulting output.

import psycopg2 
import age

GRAPH_NAME = "text_test"
DSN = "host=localhost port=5432 dbname=texttest user=afidegnum password=chou1979"
conn = psycopg2.connect(DSN)

age.setUpAge(conn, GRAPH_NAME)

def get_tree(n_id):
    """ Get the trees"""
    with conn.cursor() as cursor:
        try :                    
            cursor.execute("""
            SELECT * from cypher(%s, $$
            MATCH (V:node)-[r:connect]->(V2:node)
			WITH r as nodes,  COLLECT(V2) as children
          RETURN nodes, children
$$) as (nodes agtype, children agtype);
            """, (GRAPH_NAME,))
        
            for row in cursor:
                print(row)
                            
        except Exception as ex:
            print(ex)
            conn.rollback()


node_id = 844424930131969
                                      
get_tree(node_id)

here is the result obtained:

__init__() missing 1 required positional argument: 'cause'
line 1:189 mismatched input '::vertex' expecting '::edge'
line 1:408 mismatched input '::vertex' expecting '::edge'
line 1:682 mismatched input '::vertex' expecting '::edge'
line 1:910 mismatched input '::vertex' expecting '::edge'
line 1:1138 mismatched input '::vertex' expecting '::edge'
line 1:1370 mismatched input '::vertex' expecting '::edge'
line 1:1602 mismatched input '::vertex' expecting '::edge'
line 1:1832 mismatched input '::vertex' expecting '::edge'
line 1:2026 mismatched input '::vertex' expecting '::edge'
line 1:2239 mismatched input '::vertex' expecting '::edge'
line 1:2433 mismatched input '::vertex' expecting '::edge'

Care to look into it ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions