trustgraph/scripts/graph-show

47 lines
929 B
Text
Raw Normal View History

2024-07-10 23:20:06 +01:00
#!/usr/bin/env python3
2024-07-12 15:06:51 +01:00
"""
Connects to the graph query service and dumps all graph edges.
2024-07-12 15:06:51 +01:00
"""
import argparse
import os
from trustgraph.clients.triples_query_client import TriplesQueryClient
2024-07-12 15:06:51 +01:00
default_pulsar_host = os.getenv("PULSAR_HOST", 'pulsar://pulsar:6650')
2024-07-10 23:20:06 +01:00
def show_graph(pulsar):
2024-07-12 15:06:51 +01:00
tq = TriplesQueryClient(pulsar_host="pulsar://localhost:6650")
2024-07-12 15:06:51 +01:00
rows = tq.request(None, None, None, limit=10_000_000)
2024-07-12 15:06:51 +01:00
for row in rows:
print(row.s.value, row.p.value, row.o.value)
2024-07-12 15:06:51 +01:00
def main():
parser = argparse.ArgumentParser(
prog='graph-show',
description=__doc__,
)
parser.add_argument(
'-p', '--pulsar-host',
default=default_pulsar_host,
help=f'Pulsar host (default: {default_pulsar_host})',
2024-07-12 15:06:51 +01:00
)
args = parser.parse_args()
try:
show_graph(args.pulsar_host)
2024-07-12 15:06:51 +01:00
except Exception as e:
print("Exception:", e, flush=True)
2024-07-10 23:20:06 +01:00
2024-07-12 15:06:51 +01:00
main()
2024-07-10 23:20:06 +01:00