我只是从neo4j数据库开始。我正在用Python中的neomodel连接neo4j
为此,我创建了一个名为“kat”的新数据库,并给它一个密码——“password”。你知道吗
运行以下代码后,我可以在数据库中创建一个名为Jim的新人员:
from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,
UniqueIdProperty, RelationshipTo, RelationshipFrom)
config.DATABASE_URL = 'bolt://neo4j:password@localhost:7687'
class Country(StructuredNode):
code = StringProperty(unique_index=True, required=True)
inhabitant = RelationshipFrom('Person', 'IS_FROM')
class Person(StructuredNode):
uid = UniqueIdProperty()
name = StringProperty(unique_index=True)
age = IntegerProperty(index=True, default=0)
country = RelationshipTo(Country, 'IS_FROM')
jim = Person(name='Jim', age=3).save()
jim.age = 4
jim.save() # validation happens here
# jim.delete()
# jim.refresh() # reload properties from neo
print(jim.id) # neo4j internal id
我不明白的是,我没有在代码的任何地方提到数据库的名称,但是我仍然可以看到这个节点正在数据库中创建。有人能解释一下吗?我用这个作为安装指南-https://neomodel.readthedocs.io/en/latest/getting_started.html
在neo4j中只有一个数据库处于活动状态,它是在
conf/neo4j.conf
文件中定义的。你知道吗可以创建更多数据库,但不能同时激活多个数据库。你知道吗
如果需要,可以更改
conf/neo4j.conf
文件中的活动数据库。你知道吗更改下一行以指向新数据库。你知道吗
相关问题 更多 >
编程相关推荐