File size: 987 Bytes
2012a16 14cb01b 2012a16 c2bf5de 2012a16 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
from nebula3.Config import Config
from nebula3.gclient.net import ConnectionPool
from nebula3.mclient import MetaCache
from nebula3.gclient.net import Connection
from nebula3.graph import GraphService
import os
os.system("""
nebula-metad --daemon
nebula-storaged --daemon
nebula-graphd --daemon
""")
# 接続設定
config = Config()
config.max_connection_pool_size = 10
# 接続プールの初期化
connection_pool = ConnectionPool()
# Nebula Graph に接続
if not connection_pool.init([('127.0.0.1', 9669)], config):
print("接続に失敗しました")
exit(1)
# セッションの取得
session = connection_pool.get_session('username', 'password')
# クエリの実行
result_set = session.execute('SHOW SPACES')
# 結果の表示
if not result_set.is_succeeded():
print(result_set.error_msg())
else:
for result in result_set.rows():
print(result)
# セッションを閉じる
session.release()
# 接続プールを閉じる
connection_pool.close()
|