yes*_*eep 2 python neo4j google-compute-engine
我想知道如何让neo4j与Google Compute Engine合作.有人这样做过吗?你遇到了什么问题?
Lov*_*rma 12
干得好,
gcloud
gcloud compute ssh INSTANCE_NAME --zone AVAILABLE_ZONES
- > AVAILABLE_ZONESneo4j
在GCE中下载并安装- 您可能需要安装java(Fix)和lsof(Fix :) apt-get install lsof
.从github添加安全用户名:密码
gcloud compute firewall-rules create neo4j --network default --allow tcp:7474
./bin/neo4j start
http://IP_ADDRESS:7474/
py2neo
安装并启动服务器,请尝试一些pycode来测试它>> 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()
Run Code Online (Sandbox Code Playgroud)
在python设置/代码之上,您也可以在GAE中使用它.
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)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2122 次 |
最近记录: |