当前位置: 首页>>代码示例>>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;未经允许,请勿转载。