当neomodel 工作时,django_neomodel 无法连接到正在运行的数据库

问题描述

我按照 Getting Started 的指示在 settings.py 进行了这些设置:

NEOMODEL_NEO4J_BOLT_URL = os.environ.get('NEO4J_BOLT_URL','bolt://neo4j:password@localhost:7687')
INSTALLED_APPS = [
    'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','django_neomodel','utils'
]

但我只在使用 python manage.py install_labels 时收到此错误

neo4j.exceptions.ServiceUnavailable: [SSLCertVerificationError] Connection Failed. Please ensure that your database is listening on the correct host and port and that you have enabled encryption if required. Note that the default encryption setting has changed in Neo4j 4.0. See the docs for more information. Failed to establish encrypted connection. (code 1: Operation not permitted)

我知道数据库和 Neomodel 没问题,因为 neomodel_install_labels models.py --db bolt://neo4j:password@localhost:7687 完美运行并在数据库上创建节点。

我不知道在哪里可以找到这个异常的来源。

解决方法

来自新模型设置:

NEOMODEL_NEO4J_BOLT_URL = 'bolt://neo4j:neo4j@localhost:7687'
NEOMODEL_SIGNALS = True
NEOMODEL_FORCE_TIMEZONE = False
NEOMODEL_ENCRYPTED_CONNECTION = True
NEOMODEL_MAX_POOL_SIZE = 50

您可以看到加密设置为 True,这很可能是错误消息所说的(我怀疑您的本地 Neo4j 是否启用了加密)。

我只是将加密设置为 False :

NEOMODEL_ENCRYPTED_CONNECTION = False