I am just starting with neo4j database. I am using neomodel in Python, to connect with neo4j.
For this, I created a new database with name "kat" and gave it a password - "password".
After running the following code, I am able to create a new person called Jim in the database:
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
What I don't understand is, I have not mentioned the name of the database anywhere in the code, but still I can see this node being created in the db. Can anyone explain? I used this as a setup guide - https://neomodel.readthedocs.io/en/latest/getting_started.html
There is only one database active in neo4j and It's defined in conf/neo4j.conf
file.
You can create more databases and but cannot have multiple databases active at the same time.
If you want, you can change the active database in conf/neo4j.conf
file.
Change below line to point to new database.
dbms.active_database=graph.db