簡體   English   中英

如何使用mogwai執行gremlin查詢

[英]How to execute gremlin query with mogwai

我試圖通過mogwai查詢titan db 0.5.4,但是當我運行以下腳本時,出現錯誤:rexpro.exceptions.RexProScriptException:事務未打開

我在這里發現了同樣的問題

PS沒有mogwai標簽

腳本:

#!/usr/bin/env python3
from mogwai.connection import execute_query, setup


con = setup('127.0.0.1', graph_name="bio4j", username="re", password="re")

results = execute_query("2 * a",params={"a":2}, connection= con)
print(results)


results = execute_query("bio4j.E",params={}, connection= con)
print(results)

日志:

$ ./bin/rexster.sh --start
0    [main] INFO  com.tinkerpop.rexster.Application  - .:Welcome to Rexster:.
93   [main] INFO  com.tinkerpop.rexster.server.RexsterProperties  - Using [/Users/Phoenix/Dropbox/Graph4Bio/Titan/rexhome/config/rexster.xml] as configuration source.
102  [main] INFO  com.tinkerpop.rexster.Application  - Rexster is watching [/Users/Phoenix/Dropbox/Graph4Bio/Titan/rexhome/config/rexster.xml] for change.
730  [main] INFO  com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration  - Generated unique-instance-id=0a69045d1736-AngryMac-local1
804  [main] INFO  com.thinkaurelius.titan.diskstorage.Backend  - Initiated backend operations thread pool of size 8
905  [main] INFO  com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog  - Loaded unidentified ReadMarker start time Timepoint[1455128079919000 μs] into com.thinkaurelius.titan.diskstorage.log.kcvs.KCVSLog$MessagePuller@302c971f
908  [main] INFO  com.tinkerpop.rexster.RexsterApplicationGraph  - Graph [bio4j] - configured with allowable namespace [tp:gremlin]
932  [main] INFO  com.tinkerpop.rexster.config.GraphConfigurationContainer  - Graph bio4j - titangraph[berkeleyje:/Users/Phoenix/Dropbox/Graph4Bio/Bio4j/bio4j] loaded
939  [main] INFO  com.tinkerpop.rexster.server.metrics.HttpReporterConfig  - Configured HTTP Metric Reporter.
941  [main] INFO  com.tinkerpop.rexster.server.metrics.ConsoleReporterConfig  - Configured Console Metric Reporter.
2058 [main] INFO  com.tinkerpop.rexster.server.HttpRexsterServer  - HTTP/REST thread pool configuration: kernal[4 / 4] worker[8 / 8] 
2060 [main] INFO  com.tinkerpop.rexster.server.HttpRexsterServer  - Using org.glassfish.grizzly.strategies.LeaderFollowerNIOStrategy IOStrategy for HTTP/REST.
2160 [main] INFO  com.tinkerpop.rexster.server.HttpRexsterServer  - Rexster Server running on: [http://localhost:8182]
2160 [main] INFO  com.tinkerpop.rexster.server.RexProRexsterServer  - Using org.glassfish.grizzly.strategies.LeaderFollowerNIOStrategy IOStrategy for RexPro.
2160 [main] INFO  com.tinkerpop.rexster.server.RexProRexsterServer  - RexPro thread pool configuration: kernal[4 / 4] worker[8 / 8] 
2162 [main] INFO  com.tinkerpop.rexster.server.RexProRexsterServer  - Rexster configured with [DefaultSecurity].
2163 [main] INFO  com.tinkerpop.rexster.server.RexProRexsterServer  - RexPro Server bound to [0.0.0.0:8184]
2177 [main] INFO  com.tinkerpop.rexster.server.ShutdownManager  - Bound shutdown socket to /127.0.0.1:8183. Starting listener thread for shutdown requests.
152568 [Grizzly(2) SelectorRunner] INFO  com.tinkerpop.rexster.protocol.EngineController  - ScriptEngineManager has factory for: ECMAScript
152568 [Grizzly(2) SelectorRunner] INFO  com.tinkerpop.rexster.protocol.EngineController  - ScriptEngineManager has factory for: gremlin-groovy
152568 [Grizzly(2) SelectorRunner] INFO  com.tinkerpop.rexster.protocol.EngineController  - Registered ScriptEngine for: gremlin-groovy
152569 [Grizzly(2) SelectorRunner] INFO  com.tinkerpop.rexster.protocol.EngineHolder  - Initializing gremlin-groovy engine with additional imports.
153259 [Grizzly(2) SelectorRunner] INFO  com.tinkerpop.rexster.protocol.EngineHolder  - ScriptEngine initializing with a custom script
154074 [Grizzly(2) SelectorRunner] INFO  com.tinkerpop.rexster.protocol.EngineController  - ScriptEngineManager has factory for: Groovy
154076 [Grizzly(2) SelectorRunner] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - RexPro Session created: a2b416ce-75ea-4ecb-9835-b287162c90cb
154354 [Grizzly(4)] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - Try to destroy RexPro Session: a2b416ce-75ea-4ecb-9835-b287162c90cb
154355 [Grizzly(4)] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - RexPro Session destroyed or doesn't otherwise exist: a2b416ce-75ea-4ecb-9835-b287162c90cb
154356 [Grizzly(5)] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - RexPro Session created: 5b8a669f-615d-4f84-9d1e-2d10624347f0
154525 [Grizzly(7)] WARN  com.tinkerpop.rexster.protocol.server.ScriptServer  - Could not process script [bio4j.E] for language [groovy] on session [[B@6634722f] and request [[B@68f38099]
154527 [Grizzly(8)] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - Try to destroy RexPro Session: 5b8a669f-615d-4f84-9d1e-2d10624347f0
154527 [Grizzly(8)] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - RexPro Session destroyed or doesn't otherwise exist: 5b8a669f-615d-4f84-9d1e-2d10624347f0
154529 [Grizzly(1)] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - Try to destroy RexPro Session: 00000000-0000-0000-0000-000000000000
154529 [Grizzly(1)] INFO  com.tinkerpop.rexster.protocol.session.RexProSessions  - RexPro Session destroyed or doesn't otherwise exist: 00000000-0000-0000-0000-000000000000

mogwai的維護者在這里。

您使用的是哪個版本的mogwai? 在0.7.7中,設置方法沒有返回值,並且不應傳遞連接對象。 實際上,當您調用安裝程序時,它會創建一個連接池(由於未指定並發選項,因此它是一個同步rexpro連接池)。 因此,通常來說,只需在應用程序的生命周期內調用一次安裝程序,就可以在沒有任何引用的情況下使用執行查詢。

此外,此消息特別引人注意:

154525 [Grizzly(7)] WARN  com.tinkerpop.rexster.protocol.server.ScriptServer  - Could not process script [bio4j.E] for language [groovy] on session [[B@6634722f] and request [[B@68f38099]

您的圖形是否配置了圖形名稱“ bio4j”? 默認的泰坦圖形名稱為“ graph”,mogwai使用的默認圖形對象名稱為“ g”。 如果圖形名稱為“ bio4j”,則不會直接引用該名稱,而應使用與事務關聯的圖形對象名稱。 您可以將圖名稱視為SQL數據庫中的數據庫名稱,而圖對象是對該數據庫的事務引用。 啟動titan時,將在xml配置文件中對其進行配置。 尤其:

<graphs>
    <graph>
        <graph-name>graph</graph-name>
        ....
    </graph>
</graphs>

因此,假設您將其從“ graph”更改為“ bio4j”,並在設置函數中將默認的graph_obj_name保留為“ g”,那么您的查詢應為“ gE”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM