本文介绍了您如何设置 neo4j 以与 Google Compute Engine 配合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何让 neo4j 与 Google Compute Engine 一起工作.有没有人做过这个?您遇到了哪些问题?

解决方案

给你,

基本设置

GCE 配置

玩转

  • 启动neo4j服务器./bin/neo4j start
  • 检查您正在运行的实例@http://IP_ADDRESS:7474/

一旦 py2neo 安装和服务器启动,尝试一些 pycode 来测试它

>>从 py2neo.neo4j 导入 GraphDatabaseService,CypherQuery>># 建立到本地图数据库的链接.>># 当 () 留空时默认为 http://localhost:7474/db/data/>>图 = GraphDatabaseService('http://IP_ADDRESS:7474/db/data/')>>CypherQuery(graph, "CREATE (n {name:'Example'}) RETURN n;").execute()

以上python设置/代码,你也可以在GAE中使用.

参考文献

Appengine + Neo4j

from py2neo import neo4jGRAPH_DB = neo4j.GraphDatabaseService('http://uname:psswd@localhost:7474/db/data/')如果 IS_PROD:GRAPH_DB = neo4j.GraphDatabaseService('http://uname:psswd@host:port/db/data/')def _execute(查询):"执行所有neo4j查询并返回Record对象列表.返回:返回 Record 对象的列表."尝试:结果 = neo4j.CypherQuery(GRAPH_DB, query).execute()# logging.info(result.data)返回结果除了 neo4j.CypherError 作为错误:logging.error(error.exception)除了 DeadlineExceededError 作为死:logging.warn(死)除了 urlfetch_errors.InternalTransientError 作为 tra_error:logging.warn(tra_error)除了 httplib.HTTPException 作为 exp:logging.warn(exp)除了作为 soc 的 neo4j.http.SocketError:logging.warn(soc)

I'm wondering how one would get neo4j to work with Google Compute Engine. Has anybody done this? What problems did you encounter?

解决方案

Here you go,

Basic Setup

Configuration for GCE

Play around

  • Start neo4j server ./bin/neo4j start
  • Check your running instances @ http://IP_ADDRESS:7474/

Once py2neo Installed and server started, try some pycode to test it

>> from py2neo.neo4j import GraphDatabaseService, CypherQuery
>> # Set up a link to the local graph database.
>> # When () left blank defaults to http://localhost:7474/db/data/
>> graph = GraphDatabaseService('http://IP_ADDRESS:7474/db/data/')
>> CypherQuery(graph, "CREATE (n {name:'Example'}) RETURN n;").execute()

Above python setup / code, you can use it in GAE as well.

References

Edit: Appengine + Neo4j

from py2neo import neo4j
GRAPH_DB = neo4j.GraphDatabaseService(
        'http://uname:psswd@localhost:7474/db/data/')
if IS_PROD:
    GRAPH_DB = neo4j.GraphDatabaseService(
        'http://uname:psswd@host:port/db/data/')

def _execute(query):
    """Execute all neo4j queries and return list of Record objects.

    Returns:
      Returns list of Record objects.
    """
    try:
        result = neo4j.CypherQuery(GRAPH_DB, query).execute()
        # logging.info(result.data)
        return result
    except neo4j.CypherError as error:
        logging.error(error.exception)
    except DeadlineExceededError as dead:
        logging.warn(dead)
    except urlfetch_errors.InternalTransientError as tra_error:
        logging.warn(tra_error)
    except httplib.HTTPException as exp:
        logging.warn(exp)
    except neo4j.http.SocketError as soc:
        logging.warn(soc)

这篇关于您如何设置 neo4j 以与 Google Compute Engine 配合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 07:34