How to get the result of count in typedb / grakn?

144 Views Asked by At

I'm trying to count the instances in the base with the python API:

q = '''match
        $x isa processo;
        get $x; count;'''

with TypeDB.core_client("localhost:1729") as client:
    with client.session(keyspace, SessionType.DATA) as session:
        with session.transaction(TransactionType.READ) as read_transaction:
                    
            result = read_transaction.query().match_aggregate(q)
            print(result.get())

This prints:

<typedb.concept.answer.numeric._Numeric object at 0x00000256FCB8AA00>

How can I get the resulting number?

1

There are 1 best solutions below

0
Jorge On

I got the right result using:

print(result.get().as_int())