當前位置: 首頁>>代碼示例>>Python>>正文


Python py2neo.Graph方法代碼示例

本文整理匯總了Python中py2neo.Graph方法的典型用法代碼示例。如果您正苦於以下問題:Python py2neo.Graph方法的具體用法?Python py2neo.Graph怎麽用?Python py2neo.Graph使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在py2neo的用法示例。


在下文中一共展示了py2neo.Graph方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def __init__(self, host, port, user, password, threshold=40, secure=False, filepath=None, filename=None, folder_path=None):
        """Connects to neo4j database, loads options and set connectors.
        @raise CuckooReportError: if unable to connect.
        """
        self.threshold = int(threshold)
        self.graph = Graph(host=host, user=user, password=password, secure=secure, port=port)
        self.filepath = filepath
        self.filename = filename
        self.folder_path = folder_path
        self.scout = ApiScout()
        self.scout.setBaseAddress(0)
        self.scout.loadWinApi1024(os.path.abspath(os.path.join(os.path.dirname(__file__))) +  os.sep + "data" + os.sep + "winapi1024v1.txt")
        
        self.magictest = magic.Magic(uncompress=True)
        CWD = os.path.abspath(os.path.dirname(__file__))
        USERDB = os.path.join(CWD, os.path.normpath("data/UserDB.TXT"))
        with open(USERDB, 'rt') as f:
            sig_data = f.read()
            self.signatures = peutils.SignatureDatabase(data=sig_data)
        
        if self.folder_path:
            self.files = self.get_files(folder_path) 
開發者ID:TheHive-Project,項目名稱:Cortex-Analyzers,代碼行數:24,代碼來源:malwareclustering_api.py

示例2: get_db_client

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def get_db_client(dbhost, dbuser, dbpass, bolt=False):
    """Return a Neo4j DB session. bolt=True uses bolt driver"""    

    if verbose > 4:
        print("DB Creds", dbhost, dbuser, dbpass)

    if bolt:
        bolt_url = "bolt://" + dbhost
        auth_token = basic_auth(dbuser, dbpass)
        try:
            driver = GraphDatabase.driver(bolt_url, auth=auth_token, max_pool_size=5)
            bolt_session = driver.session()
            return bolt_session
        except Exception as e:
            print("Database connection/authentication error:", e)
            sys.exit(1)
    else:
        login = "http://{0}:{1}@{2}:7474/db/data/".format(dbuser, dbpass, dbhost)
        py2neo_session = Graph(login)
        return py2neo_session 
開發者ID:yantisj,項目名稱:netgrph,代碼行數:22,代碼來源:__init__.py

示例3: __init__

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def __init__(self, host, port, username=None, password=None, ssl=False, timeout=None, bolt=None):
    if timeout is not None:
      http.socket_timeout = timeout

    host_port = "{host}:{port}".format(host=host, port=port)
    uri = "{scheme}://{host_port}/db/data/".format(scheme="https" if ssl else "http", host_port=host_port)

    self.graph = Graph(uri, user=username, password=password, bolt=bolt, secure=ssl)

    try:
      self.neo4j_version = self.graph.dbms.kernel_version
    except Unauthorized:
      raise AuthError(uri)
    except SocketError:
      raise ConnectionError(uri) 
開發者ID:nicolewhite,項目名稱:cycli,代碼行數:17,代碼來源:driver.py

示例4: __init__

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def __init__(self, credentials):
        BaseGraph.__init__(self)
        self._type = "neo4j"
        self.graph = Graph(credentials)
        self.path = os.getcwd() + "\\csv"
        if not os.path.exists(self.path):
            os.mkdir(self.path) 
開發者ID:shobeir,項目名稱:GraphiPy,代碼行數:9,代碼來源:graph_neo4j.py

示例5: __init__

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def __init__(self):
        cur_dir = os.path.abspath(os.path.dirname(__file__))
        self.data_path = os.path.join(cur_dir, '../..', 'data/medical_sample.json')
        self.g = Graph(
            host=host,  # neo4j 搭載服務器的ip地址,ifconfig可獲取到
            http_port=kg_port,  # neo4j 服務器監聽的端口號
            user=user,  # 數據庫user name,如果沒有更改過,應該是neo4j
            password=password) 
開發者ID:shibing624,項目名稱:dialogbot,代碼行數:10,代碼來源:build_medicalgraph.py

示例6: __init__

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def __init__(self):
        try:
            self.g = Graph(
                host=host,
                http_port=kg_port,
                user=user,
                password=password)
        except Exception as e:
            logger.error('service down. please open neo4j service. %s' % e)
        self.num_limit = answer_num_limit 
開發者ID:shibing624,項目名稱:dialogbot,代碼行數:12,代碼來源:answer_searcher.py

示例7: neo

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def neo(graph: BELGraph, connection: str, password: str):
    """Upload to neo4j."""
    import py2neo
    neo_graph = py2neo.Graph(connection, password=password)
    to_neo4j(graph, neo_graph) 
開發者ID:pybel,項目名稱:pybel,代碼行數:7,代碼來源:cli.py

示例8: test_neo4j_remote

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def test_neo4j_remote(self, mock_get):
        from py2neo.database.status import GraphError
        from py2neo import Graph

        test_context = 'PYBEL_TEST_CTX'
        neo_path = os.environ['NEO_PATH']

        try:
            neo = Graph(neo_path)
            neo.data('match (n)-[r]->() where r.{}="{}" detach delete n'.format(PYBEL_CONTEXT_TAG, test_context))
        except GraphError:
            self.skipTest("Can't query Neo4J ")
        except Exception:
            self.skipTest("Can't connect to Neo4J server")
        else:
            with self.runner.isolated_filesystem():
                args = [
                    'convert',
                    '--path', test_bel_simple,
                    '--connection', self.connection,
                    '--neo', neo_path,
                    '--neo-context', test_context
                ]
                self.runner.invoke(cli.main, args)

                q = 'match (n)-[r]->() where r.{}="{}" return count(n) as count'.format(PYBEL_CONTEXT_TAG, test_context)
                count = neo.data(q)[0]['count']
                self.assertEqual(14, count) 
開發者ID:pybel,項目名稱:pybel,代碼行數:30,代碼來源:test_cli.py

示例9: __init__

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def __init__(self, username='neo4j', password='admin', bolt=7687):
        self.graph = Graph(user=username, password=password, bolt_port=bolt) 
開發者ID:weihesdlegend,項目名稱:Autocomplete-System,代碼行數:4,代碼來源:Database.py

示例10: neo4j_query_data

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def neo4j_query_data(cypher, parameters=None, **kwparameters):

    if type(cypher) != str:
        print('Cypher query needs to be a string')
        return pd.DataFrame([])

    if len(cypher) == 0:
        print('Cypher query cannot be empty')
        return pd.DataFrame([])

    if parameters and type(parameters) != dict:
        print('Parameters need to be a dictionary')
        return pd.DataFrame([])

    neo4j_username = config.get_value('neo4j', 'neo4j_username')
    neo4j_password = config.get_value('neo4j', 'neo4j_password')
    neo4j_address = config.get_value('neo4j', 'neo4j_address')

    secure_graph = Graph("bolt://{}:{}@{}".format(neo4j_username, neo4j_password, neo4j_address))

    try:
        results = secure_graph.run(cypher, parameters, **kwparameters)
    except ClientError as e:
        print('There was an issue with the cypher query')
        print(e)
        return pd.DataFrame([])
    except AttributeError as e:
        print('There was an authentication issue')
        print(e)
        return pd.DataFrame([])

    results_pandas = pd.DataFrame(results.data())

    return results_pandas 
開發者ID:Wikia,項目名稱:sroka,代碼行數:36,代碼來源:neo4j_api.py

示例11: __init__

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def __init__(self):
        self.g = Graph(
            host="127.0.0.1",
            http_port=7474,
            user="",
            password=""
        ) 
開發者ID:pengyou200902,項目名稱:Doctor-Friende,代碼行數:9,代碼來源:create_graph.py

示例12: connectDB

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def connectDB(self):
		self.graph = Graph("http://localhost:7474", username="neo4j", password="8313178") 
開發者ID:qq547276542,項目名稱:Agriculture_KnowledgeGraph,代碼行數:4,代碼來源:neo_models.py

示例13: connectDB

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def connectDB(self):
		self.graph = Graph("http://localhost:7474", username="neo4j", password="123456") 
開發者ID:qq547276542,項目名稱:Agriculture_KnowledgeGraph,代碼行數:4,代碼來源:neo_models.py

示例14: connectDB

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def connectDB(self):
		self.graph = Graph("http://localhost:7474",username = "neo4j" , password = "8313178")
		print("connect neo4j success!") 
開發者ID:qq547276542,項目名稱:Agriculture_KnowledgeGraph,代碼行數:5,代碼來源:relationDataProcessing.py

示例15: connectDB

# 需要導入模塊: import py2neo [as 別名]
# 或者: from py2neo import Graph [as 別名]
def connectDB(self):
		self.graph = Graph("http://localhost:7474", username="neo4j", password="8313178")
		print('connect successed') 
開發者ID:qq547276542,項目名稱:Agriculture_KnowledgeGraph,代碼行數:5,代碼來源:neo_models.py


注:本文中的py2neo.Graph方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。