SchemaInspector API¶
SchemaInspector discovers your ArangoDB structure at runtime. See the Schema Introspection guide for usage patterns.
Constructor¶
| Parameter | Type | Default | Description |
|---|---|---|---|
db |
StandardDatabase |
required | A connected python-arango database |
max_sample_docs |
int |
5 |
Documents sampled per collection to discover fields |
get_schema_map¶
Returns the full schema map. Cached after the first call; pass refresh=True to rebuild.
schema = inspector.get_schema_map()
schema["database_name"] # str
schema["collections"] # list of document collections
schema["edges"] # list of edge collections
Shape:
{
"database_name": "my_graph",
"collections": [
{"name": "ExtractedEntities", "type": "document",
"count": 12345, "fields": ["_key", "name", "type", ...]},
...
],
"edges": [
{"name": "ExtractedRelationships", "count": 45678,
"from_collections": ["ExtractedEntities"],
"to_collections": ["ExtractedEntities"],
"fields": ["_from", "_to", "relation", ...]},
...
],
}
System collections (names starting with _) are skipped.
get_collection_info¶
Returns the schema entry for a document or edge collection, or None if not found.
get_edge_info¶
Returns the schema entry for an edge collection, including its from_collections and to_collections.
edge = inspector.get_edge_info("ExtractedRelationships")
edge["from_collections"] # e.g. ["ExtractedEntities"]
edge["to_collections"] # e.g. ["ExtractedEntities"]
inspect_arango_schema¶
Convenience one-call helper: builds the schema map and optionally writes it to output_file as JSON.
Use the exported file to prime an agent, generate documentation, or validate structures across environments.
Data classes¶
The inspector returns plain dictionaries, backed internally by these dataclasses:
| Dataclass | Fields |
|---|---|
CollectionSchema |
name, type, count, fields |
EdgeSchema |
name, count, from_collections, to_collections, fields |
SchemaMap |
database_name, collections, edges |