From 46a0212817302ca9e1e0140281747472d8b03ffe Mon Sep 17 00:00:00 2001 From: Edouard Schweisguth Date: Tue, 31 Oct 2023 19:41:38 +0100 Subject: [PATCH 1/2] Add data query pattern from python --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 5dc0e85fd..3741f46fb 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,24 @@ To query the KubeHound graph data requires using the [Gremlin](https://tinkerpop + Create a connection to the local janusgraph instance by following the steps here https://docs.gdotv.com/connection-management/ and using `hostname=localhost` + Navigate to the query editor and enter a sample query e.g `g.V().count()`. See detailed instructions here: https://docs.gdotv.com/query-editor/#run-your-query +### Query data from other language + +#### Python + +You can query the database data in your python script by using the following snippet: + +```python +#!/usr/bin/env python +import sys +from gremlin_python.driver.client import Client + +KH_QUERY = "kh.containers().count()" +c = Client("ws://127.0.0.1:8182/gremlin", "kh") +results = c.submit(KH_QUERY).all().result() +``` + +You'll need to install `gremlinpython` as a dependency via: `pip install gremlinpython` + ## Development ### Build From ef617d32a72b4500a20ccf2461a380e33fb71906 Mon Sep 17 00:00:00 2001 From: Edouard Schweisguth Date: Tue, 31 Oct 2023 19:43:07 +0100 Subject: [PATCH 2/2] rewording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3741f46fb..02a23c6c8 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ To query the KubeHound graph data requires using the [Gremlin](https://tinkerpop + Create a connection to the local janusgraph instance by following the steps here https://docs.gdotv.com/connection-management/ and using `hostname=localhost` + Navigate to the query editor and enter a sample query e.g `g.V().count()`. See detailed instructions here: https://docs.gdotv.com/query-editor/#run-your-query -### Query data from other language +### Query data from your scripts #### Python