import py2neo from py2neo import neo4j py2neo.authenticate("localhost:7474", "neo4j", "SomeRandomPasswordString") graph = neo4j.Graph("https://localhost:7474") graph.legacy.get_or_create_index(neo4j.Node, "FooBar")