1

I'm trying to start a project using Neo4j Aura and neomodel. I've found this post and set up my connection as suggested, however when I try to run my project I get the following error:

ValueError: Expecting url format: bolt://user:password@localhost:7687 got neo4j+s://myuser:mypass@mydb.databases.neo4j.io

I've checked the neomodel code and it specifically checks for the bolt protocol and won't continue with the neo4j+s protocol. This differs from what is suggested in the post I linked - am I missing something? I would greatly appreciate a hint in the right direction.

Here is the example code I'm trying to run:

import os

from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,
                      UniqueIdProperty, RelationshipTo)
from dotenv import load_dotenv

if __name__ == '__main__':
    load_dotenv()

    user = os.environ['NEO4J_USERNAME']
    psw = os.environ['NEO4J_PASSWORD']
    uri = os.environ['NEO4J_URI']

    config.DATABASE_URL = 'neo4j+s://{}:{}@{}'.format(user, psw, uri)


    class Country(StructuredNode):
        code = StringProperty(unique_index=True, required=True)


    class Person(StructuredNode):
        uid = UniqueIdProperty()
        name = StringProperty(unique_index=True)
        age = IntegerProperty(index=True, default=0)

        # traverse outgoing IS_FROM relations, inflate to Country objects
        country = RelationshipTo(Country, 'IS_FROM')


    jim = Person(name='Jim', age=3).save()  # Create
    jim.age = 4
    jim.save()  # Update, (with validation)
Anthu
  • 13
  • 3

1 Answers1

0

Please advise your neo4j version and neo4j driver version. Bolt protocol is previously used in neo4j drivers 1.7 while neo4j protocol is for neo4j version 4.x. This protocol neo4j+s is equivalent to bolt+routing in older version. Then, I tried your code and it is working well. Notice the db aura uri at the bottom of the image.

To check your neo4j versions, open a terminal and type "pip freeze | grep neo4j". This is my driver version:

neo4j==4.4.5
neo4j-driver==4.3.6  
neomodel==4.0.8

Result: enter image description here

jose_bacoy
  • 12,227
  • 1
  • 20
  • 38
  • Thank you for your answer jose! I have the following versions installed (through pip install): neo4j-driver==1.7.2 neobolt==1.7.17 neomodel==3.3.2 neotime==1.7.4 – Anthu Sep 26 '22 at 17:43
  • there you go! neo4j-driver==1.7.2 means you are still using an older version of neo4j -driver. Install a newer versions then you will be fine. – jose_bacoy Sep 26 '22 at 17:52
  • After adjusting to the specific versions you mentioned, my requirements.txt file looks like this: neomodel python-dotenv neo4j-driver == 4.3.6 neo4j == 4.4.5 neo4jrestclient == 2.1.1 When I try to run my code now I get the following error: ModuleNotFoundError: No module named 'neo4j.v1' – Anthu Sep 26 '22 at 17:53
  • you are now upgrading your neo4j 3.5 to ver:4. Lots of other things needs to be done and it is not easy. You can following this documentation. 1) https://neo4j.com/docs/upgrade-migration-guide/current/migration/surface-changes/ 2) https://neo4j.com/docs/upgrade-migration-guide/current/migration/drivers/ Goodluck! – jose_bacoy Sep 26 '22 at 17:55
  • Thanks for your help jose. After a reset of my venv I've indentified my problem. I had Python 3.1x installed but the neomodel package relies on shapely 1.7.1, which only works with Python 3.7x. I'm using pyCharm and apparently it reverted to the earliest working version of neomodel for 3.1x, which seems to not include the neo4j+s protocol. After changing my interpreter to 3.7x and reinstalling everything it now works. However I'm still getting the following error, even though the node is created in the db: Failed to write data to connection IPv4Address(('x.databases.neo4j.io', 7687)) – Anthu Sep 26 '22 at 18:48
  • I managed to get rid of the error by going to neo4j-driver 4.1.3 as specified on the neomodel github. I think that solves my problem and I can start with the actual project :) Thanks a lot for your help! – Anthu Sep 26 '22 at 19:11
  • Glad it worked well for you! We're here to help – jose_bacoy Sep 26 '22 at 19:49