【问题标题】:Using neo4django with apache将 neo4django 与 apache 一起使用
【发布时间】:2013-07-10 07:30:28
【问题描述】:

我正在尝试在托管在Apache 服务器上的django 网站上使用neo4j 数据库。我正在使用neo4django。我已按照http://neo4django.readthedocs.org/en/v0.1.8/index.html 中的说明进行操作。创建节点时,出现以下错误:

error at /disk/ [Errno 111] Connection refused Request

我的models.py:

import django.db
from neo4django.db import models

class Person(django.db.models.Model):
name = django.db.models.CharField(max_length=50, null=True, blank=True)
username = django.db.models.CharField(max_length=50, null=True, blank=True)
password=django.db.models.CharField(max_length=50, null=True, blank=True)
email=django.db.models.CharField(max_length=50, null=True, blank=True)

    class Meta:
        db_table='lt_profile'

class Pnode(models.NodeModel):
    name=models.StringProperty()
    #more fields

class Anode(models.NodeModel):
    art_type=models.StringProperty(max_length=50)
    mtime=models.StringProperty(max_length=200)

#relation:

我的设置.py:

NEO4J_DATABASES = {
    'default' : {
        'HOST':'localhost',
        'PORT': 7474,
        'ENDPOINT':'/var/www/graph_db'
    }
}

DATABASE_ROUTERS = ['neo4django.utils.Neo4djangoIntegrationRouter']

发生错误的代码:

a = Anode.objects.create(art_type='py', mtime=str(file_mtime))
a.save()

我想我需要更改我在 Apache 中的 port.conf 文件中的某些内容,但我不知道该怎么做。我试过这样的事情:

ports.conf 中收听 7474,但没有运气。任何帮助将不胜感激。谢谢

【问题讨论】:

  • python 版本:2.7 和 neo4django 版本 1.8
  • 我觉得你的endpoint不对——应该是neo4django可以连接的外部路径。没有时间发表评论。

标签: python django apache neo4j neo4django


【解决方案1】:

@Wes 就在 cmets 中——您的端点应该设置为相对 URL,而不是文件路径。

From the docs,试试'ENDPOINT':'/db/data',这是 Neo4j 的默认设置。

编辑:

其他一些建议:

您绝对不需要在 Apache 配置中添加任何内容。 Apache 从 Django 提供您的内容,但不控制您可以从 Django 访问哪些端口 - 它的配置文件仅涵盖外部用户可以访问的端口。事实上,如果 Apache 被配置为侦听 7474 并且它与 Neo4j 在同一台服务器上,其中一个将无法使用该端口。

在您的代码中,您使用a = Anode.objects.create(...),后跟a.save()Anode.objects.create() 是一个快捷方式

a = Anode(...)
a.save()

所以你实际上节省了两次。我会使用其中一种来避免不必要地频繁访问数据库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-04
    • 2011-09-12
    • 2020-01-17
    • 2012-04-26
    • 2012-07-21
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多