私はneo4jデータベースから始めたばかりです。私はneo4jと接続するために、Pythonでneomodelを使用しています。
このために、「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