2017-04-25 1 views
0

こんにちは、私はポート7687でlocalhostに接続できません。 /app/.heroku/python/lib/python3:私のPythonコードは、このコードは私の地元のsyatem上で細かい実行されているが、HerokuのとgraphenedbherokuでホストされているGraphenedbへの接続エラー

例外の場所に展開されたときに接続エラーを与えている

import os 
import json 
from urllib.parse import urlparse, urlunparse 

from django.shortcuts import render 

# Create your views here. 
from py2neo import Graph, authenticate 
from bottle import get,run,request,response,static_file 
from py2neo.packages import neo4j 

url = urlparse(os.environ.get("GRAPHENEDB_GOLD_URL")) 
url_without_auth = urlunparse((url.scheme, ("{0}:{1}").format(url.hostname, url.port), '', None, None, None)) 
user = url.username 
password = url.password 
authenticate(url_without_auth,user, password) 
graph = Graph(url_without_auth, bolt = False) 

#graph = Graph(password='[email protected]') 


@get("/") 
def get_index(): 
    return static_file("index.html", root="static") 


@get("/graph") 
def get_graph(self): 
    print("i was here") 
    print("graph start") 
    results = graph.run(
     "MATCH (m:Movie)<-[:ACTED_IN]-(a:Person) " 
     "RETURN m.title as movie, collect(a.name) as cast " 
     "LIMIT {limit}", {"limit": 10}) 
    print("graph run the run") 
    nodes = [] 
    rels = [] 
    i = 0 
    for movie, cast in results: 
     #print("i am here") 
     nodes.append({"title": movie, "label": "movie"}) 
     target = i 
     i += 1 
     for name in cast: 
      print(name) 
      actor = {"title": name, "label": "actor"} 
      try: 
       source = nodes.index(actor) 
      except ValueError: 
       nodes.append(actor) 
       source = i 
       i += 1 
      rels.append({"source": source, "target": target}) 
    return {"nodes": nodes, "links": rels} 


@get("/search") 
def get_search(): 
    try: 
     q = request.query["q"] 
    except KeyError: 
     return [] 
    else: 
     results = graph.run(
      "MATCH (movie:Movie) " 
      "WHERE movie.title =~ {title} " 
      "RETURN movie", {"title": "(?i).*" + q + ".*"}) 
     response.content_type = "application/json" 
     return json.dumps([{"movie": dict(row["movie"])} for row in results]) 


@get("/movie/<title>") 
def get_movie(title): 
    results = graph.run(
     "MATCH (movie:Movie {title:{title}}) " 
     "OPTIONAL MATCH (movie)<-[r]-(person:Person) " 
     "RETURN movie.title as title," 
     "collect([person.name, head(split(lower(type(r)),'_')), r.roles]) as cast " 
     "LIMIT 1", {"title": title}) 
    row = results.next() 
    return {"title": row["title"], 
      "cast": [dict(zip(("name", "job", "role"), member)) for member in row["cast"]]} 

を実行したときにエラー.6/site-packages/py2neo/packages/neo4j/v1/connection.py in接続387

答えて

1

私はJuanjoです(GrapheneDBから)。

一見したところ、コードは正常に見え、エラーコードは間違ったURLを指しています。環境変数に問題がある可能性があります。 GRAPHENEDB_GOLD_URL変数を確認してください。

あなたはこのようにそれを行うことができます:あなたの変数が空の場合は

http://<user>:<pass>@XXX.graphenedb.com:24789/db/data 

(ここではあなたのURLを共有しないでください)

:それはのようなものでなければなりません

$ heroku config:get GRAPHENEDB_GOLD_URL 

をGrapheneDB環境変数の取得については、hereをお読みください。

問題が解決しない場合や問題が解決しない場合は、管理パネルのサポートリンクからお問い合わせください。 Herokuチームはサポートチケットを私たちに転送し、データベースに関連するすべての情報をチケットに挿入します。

おかげで、

フアンホ

関連する問題