Spaces:
Paused
Paused
| from neo4j import GraphDatabase | |
| d = GraphDatabase.driver( | |
| "neo4j+s://054eff27.databases.neo4j.io", | |
| auth=("neo4j", "Qrt37mkb0xBZ7_ts5tG1J70K2mVDGPMF2L7Njlm7cg8") | |
| ) | |
| with d.session() as s: | |
| print("=" * 50) | |
| print("π NEO4J KNOWLEDGE GRAPH STATUS") | |
| print("=" * 50) | |
| # Node counts by label | |
| r = s.run(""" | |
| MATCH (n) | |
| RETURN labels(n)[0] as label, count(*) as count | |
| ORDER BY count DESC LIMIT 20 | |
| """) | |
| print("\nπ¦ NODES BY TYPE:") | |
| total = 0 | |
| for x in r: | |
| print(f" {x['label']}: {x['count']:,}") | |
| total += x['count'] | |
| print(f" βββββββββββββββββ") | |
| print(f" TOTAL: {total:,}") | |
| # Relationship counts | |
| r = s.run(""" | |
| MATCH ()-[r]->() | |
| RETURN type(r) as type, count(*) as count | |
| ORDER BY count DESC LIMIT 10 | |
| """) | |
| print("\nπ RELATIONSHIPS:") | |
| for x in r: | |
| print(f" {x['type']}: {x['count']:,}") | |
| # Recent LocalFile samples | |
| r = s.run(""" | |
| MATCH (lf:LocalFile) | |
| RETURN lf.name as name, lf.category as cat, lf.fileType as type | |
| ORDER BY lf.harvestedAt DESC | |
| LIMIT 10 | |
| """) | |
| print("\nπ RECENT LOCAL FILES:") | |
| for x in r: | |
| print(f" [{x['cat']}] {x['name'][:40]} ({x['type']})") | |
| d.close() | |