【问题标题】:Joern: access graph database directly without neo4j-serverJoern:无需​​ Neo4j-server 直接访问图数据库
【发布时间】:2016-11-05 23:51:46
【问题描述】:

joern documentation 说:

可以直接从您的脚本访问图形数据库 通过在脚本启动时将数据库加载到内存中。

你怎么能这样做?

运行后 java -jar $JOERN/bin/joern.jar $CodeDirectory 在我的代码中,使用所有这些 .id 和 .db 文件创建了一个 Neo4J 数据库目录 (.joernIndex)。 to access my code (with python-joern) without 是否可以运行 neo4j 服务器? (需要服务器吗?)

【问题讨论】:

    标签: java python neo4j graph-databases


    【解决方案1】:

    此处记录了使用 Joern 数据库的 Web 界面方式:

    http://joern.readthedocs.io/en/latest/import.html

    这里记录了 python-joern 接口:

    http://joern.readthedocs.io/en/latest/access.html#python-joern-api

    还有程序:

    from joern.all import JoernSteps
    
    j = JoernSteps()
    
    j.setGraphDbURL('http://localhost:7474/db/data/')
    
    # j.addStepsDir('Use this to inject utility traversals')
    
    j.connectToDatabase()
    
    res =  j.runGremlinQuery('getFunctionsByName("main")')
    res =  j.runCypherQuery('...')
    
    for r in res: print r
    

    基本上是与 Neo4J 服务器通信的 URL 方式,这被称为 Joern 的“REST API”。

    现在如果你想“直接”访问数据库,你可以使用一些 Java 程序,如下所示:

    Loading all Neo4J db to RAM

    或者一些python,如下所示:

    https://neo4j.com/developer/python/

    https://marcobonzanini.com/2015/04/06/getting-started-with-neo4j-and-python/

    但归根结底,您仍将启动 Neo4J 数据库服务器,并且您的程序(通过 neo4j 驱动程序,使基于网络的通信成为可能)与数据库服务器通信。

    但如果你想直接加载“数据库”文件,自己解析,然后提取数据,那就很难了。

    【讨论】:

      猜你喜欢
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多