当前位置: 首页>>代码示例>>Python>>正文


Python GraphDatabase.driver方法代码示例

本文整理汇总了Python中neo4j.GraphDatabase.driver方法的典型用法代码示例。如果您正苦于以下问题:Python GraphDatabase.driver方法的具体用法?Python GraphDatabase.driver怎么用?Python GraphDatabase.driver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neo4j.GraphDatabase的用法示例。


在下文中一共展示了GraphDatabase.driver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_must_use_valid_url_scheme

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_must_use_valid_url_scheme(self):
     try:
         GraphDatabase.driver("x://xxx")
     except ValueError:
         assert True
     else:
         assert False
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:9,代码来源:session_test.py

示例2: test_can_run_simple_statement

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_run_simple_statement(self):
     session = GraphDatabase.driver("bolt://localhost").session()
     count = 0
     for record in session.run("RETURN 1 AS n"):
         assert record[0] == 1
         assert record["n"] == 1
         try:
             record["x"]
         except AttributeError:
             assert True
         else:
             assert False
         assert record.n == 1
         try:
             record.x
         except AttributeError:
             assert True
         else:
             assert False
         try:
             record[object()]
         except TypeError:
             assert True
         else:
             assert False
         assert repr(record)
         assert len(record) == 1
         count += 1
     session.close()
     assert count == 1
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:32,代码来源:session_test.py

示例3: __init__

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
    def __init__(self, options, columns):

        # Calling super constructor
        super(Neo4jForeignDataWrapper, self).__init__(options, columns)

        # Managed server option
        if 'url' not in options:
            log_to_postgres('The Bolt url parameter is required and the default is "bolt://localhost:7687"', WARNING)
        self.url = options.get("url", "bolt://localhost:7687")

        if 'user' not in options:
            log_to_postgres('The user parameter is required  and the default is "neo4j"', ERROR)
        self.user = options.get("user", "neo4j")

        if 'password' not in options:
            log_to_postgres('The password parameter is required for Neo4j', ERROR)
        self.password = options.get("password", "")

        if 'cypher' not in options:
            log_to_postgres('The cypher parameter is required', ERROR)
        self.cypher = options.get("cypher", "MATCH (n) RETURN n LIMIT 100")

        # Setting table columns
        self.columns = columns

        # Create a neo4j driver instance
        self.driver = GraphDatabase.driver( self.url, auth=basic_auth(self.user, self.password))

        self.columns_stat = self.compute_columns_stat()
        self.table_stat = int(options.get("estimated_rows", -1))
        if(self.table_stat < 0):
            self.table_stat = self.compute_table_stat()
        log_to_postgres('Table estimated rows : ' + unicode(self.table_stat), DEBUG)
开发者ID:sim51,项目名称:neo4j-fdw,代码行数:35,代码来源:neo4jfdw.py

示例4: test_can_obtain_summary_info

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_obtain_summary_info(self):
     with GraphDatabase.driver("bolt://localhost").session() as session:
         result = session.run("CREATE (n) RETURN n")
         summary = result.summarize()
         assert summary.statement == "CREATE (n) RETURN n"
         assert summary.parameters == {}
         assert summary.statement_type == "rw"
         assert summary.statistics.nodes_created == 1
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:10,代码来源:session_test.py

示例5: test_fails_on_bad_syntax

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_fails_on_bad_syntax(self):
     session = GraphDatabase.driver("bolt://localhost").session()
     try:
         session.run("X").consume()
     except CypherError:
         assert True
     else:
         assert False
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:10,代码来源:session_test.py

示例6: test_fails_on_missing_parameter

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_fails_on_missing_parameter(self):
     session = GraphDatabase.driver("bolt://localhost").session()
     try:
         session.run("RETURN {x}").consume()
     except CypherError:
         assert True
     else:
         assert False
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:10,代码来源:session_test.py

示例7: test_can_run_statement_that_returns_multiple_records

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_run_statement_that_returns_multiple_records(self):
     session = GraphDatabase.driver("bolt://localhost").session()
     count = 0
     for record in session.run("unwind(range(1, 10)) AS z RETURN z"):
         assert 1 <= record[0] <= 10
         count += 1
     session.close()
     assert count == 10
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:10,代码来源:session_test.py

示例8: test_can_handle_cypher_error

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_handle_cypher_error(self):
     with GraphDatabase.driver("bolt://localhost").session() as session:
         try:
             session.run("X")
         except CypherError:
             assert True
         else:
             assert False
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:10,代码来源:session_test.py

示例9: test_can_return_relationship

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_return_relationship(self):
     with GraphDatabase.driver("bolt://localhost").session() as session:
         result = session.run("MERGE ()-[r:KNOWS {since:1999}]->() RETURN r")
         assert len(result) == 1
         for record in result:
             rel = record[0]
             assert isinstance(rel, Relationship)
             assert rel.type == "KNOWS"
             assert rel.properties == {"since": 1999}
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:11,代码来源:session_test.py

示例10: test_can_return_node

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_return_node(self):
     with GraphDatabase.driver("bolt://localhost").session() as session:
         result = session.run("MERGE (a:Person {name:'Alice'}) RETURN a")
         assert len(result) == 1
         for record in result:
             alice = record[0]
             assert isinstance(alice, Node)
             assert alice.labels == {"Person"}
             assert alice.properties == {"name": "Alice"}
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:11,代码来源:session_test.py

示例11: test_can_obtain_plan_info

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_obtain_plan_info(self):
     with GraphDatabase.driver("bolt://localhost").session() as session:
         result = session.run("EXPLAIN CREATE (n) RETURN n")
         plan = result.summarize().plan
         assert plan.operator_type == "ProduceResults"
         assert plan.identifiers == ["n"]
         assert plan.arguments == {"planner": "COST", "EstimatedRows": 1.0, "version": "CYPHER 3.0",
                                   "KeyNames": "n", "runtime-impl": "INTERPRETED", "planner-impl": "IDP",
                                   "runtime": "INTERPRETED"}
         assert len(plan.children) == 1
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:12,代码来源:session_test.py

示例12: test_can_obtain_profile_info

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_obtain_profile_info(self):
     with GraphDatabase.driver("bolt://localhost").session() as session:
         result = session.run("PROFILE CREATE (n) RETURN n")
         profile = result.summarize().profile
         assert profile.db_hits == 0
         assert profile.rows == 1
         assert profile.operator_type == "ProduceResults"
         assert profile.identifiers == ["n"]
         assert profile.arguments == {"planner": "COST", "EstimatedRows": 1.0, "version": "CYPHER 3.0",
                                      "KeyNames": "n", "runtime-impl": "INTERPRETED", "planner-impl": "IDP",
                                      "runtime": "INTERPRETED", "Rows": 1, "DbHits": 0}
         assert len(profile.children) == 1
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:14,代码来源:session_test.py

示例13: test_can_run_simple_statement_from_bytes_string

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_run_simple_statement_from_bytes_string(self):
     session = GraphDatabase.driver("bolt://localhost").session()
     count = 0
     for record in session.run(b"RETURN 1 AS n"):
         assert record[0] == 1
         assert record["n"] == 1
         assert record.n == 1
         assert repr(record)
         assert len(record) == 1
         count += 1
     session.close()
     assert count == 1
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:14,代码来源:session_test.py

示例14: test_can_return_path

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
 def test_can_return_path(self):
     with GraphDatabase.driver("bolt://localhost").session() as session:
         result = session.run("MERGE p=({name:'Alice'})-[:KNOWS]->({name:'Bob'}) RETURN p")
         assert len(result) == 1
         for record in result:
             path = record[0]
             assert isinstance(path, Path)
             assert path.start.properties == {"name": "Alice"}
             assert path.end.properties == {"name": "Bob"}
             assert path.relationships[0].type == "KNOWS"
             assert len(path.nodes) == 2
             assert len(path.relationships) == 1
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:14,代码来源:session_test.py

示例15: test_can_rollback_transaction_using_with_block

# 需要导入模块: from neo4j import GraphDatabase [as 别名]
# 或者: from neo4j.GraphDatabase import driver [as 别名]
    def test_can_rollback_transaction_using_with_block(self):
        with GraphDatabase.driver("bolt://localhost").session() as session:
            with session.new_transaction() as tx:
                # Create a node
                result = tx.run("CREATE (a) RETURN id(a)")
                node_id = result[0][0]
                assert isinstance(node_id, int)

                # Update a property
                tx.run("MATCH (a) WHERE id(a) = {n} "
                       "SET a.foo = {foo}", {"n": node_id, "foo": "bar"})

            # Check the property value
            result = session.run("MATCH (a) WHERE id(a) = {n} "
                                 "RETURN a.foo", {"n": node_id})
            assert len(result) == 0
开发者ID:chiffa,项目名称:neo4j-python-driver,代码行数:18,代码来源:session_test.py


注:本文中的neo4j.GraphDatabase.driver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。