Francois, seesm there was a number of hickups with this code snippet. Try out this:
--------------------------------------------- import neo4j from neo4j.util import Subreference #Then re open it in other function and added some nodes and indexes #open databse graphdb = neo4j.GraphDatabase("database") with graphdb.transaction: #create or get root indexes rootindex = graphdb.index("root_index", create=True) #Categories****************************************************************** #get categories root nodes categorynode = rootindex["Categories"] #create or get categories root nodes sectornode = Subreference.Node.SECTOR_ROOT(graphdb, label="Sectors", level=1) try: ls_message = ls_message + categorynode["label"] + ", " except: categorynode = graphdb.node(label="Categories", level=2) rootindex["Categories"] = categorynode graphdb.shutdown() ----------------------------------------------- And you should get something like the attached image. Does that help? Cheers, /peter neubauer VP Product Development, Neo Technology GTalk: neubauer.peter Skype peter.neubauer Phone +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter http://twitter.com/peterneubauer http://www.neo4j.org - Your high performance graph database. http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. On Fri, Sep 17, 2010 at 11:45 AM, Francois Kassis <francois_kas...@hotmail.com> wrote: > Ups sorry it's my mistake. actually it was tx.success() instead of > tx.finish() and still everything is save but the indexes. > > > > From: Francois Kassis > Sent: Friday, September 17, 2010 12:20 PM > To: user@lists.neo4j.org > Subject: Saving indexes in neo4j.py > > > Hi all, > I create a new database "neodatabse" using neo4j python version. > > #create new databse > graphdb = neo4j.GraphDatabse("neodatabse") > graphdb.shutdown() > > Then re open it in other function and added some nodes and indexes > #open databse > graphdb = neo4j.GraphDatabse("neodatabse") > try: > tx = graphdb.transaction.begin() > > #create or get root indexes > rootindex = graphdb.index("root_index", create=True) > > > #Categories****************************************************************** > #get categories root nodes > categorynode = rootindex["Categories"] > #create or get categories root nodes > sectornode = Subreference.Node.SECTOR_ROOT(graphdb, label="Sectors", > level=1) > try: > ls_message = ls_message + categorynode["label"] + ", " > except: > categorynode = graphdb.node(label="Categories", level=2) > rootindex["Categories"] = categorynode > except: > tx.failure() > else: > tx.finish() > finally: > tx.finish() > > graphdb.shutdown() > > If I run the above script the "Category node will be created twice. it look > like neo4j.py is not saving the indexses in database, any clue? > THX. > Francois. > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user >
<<attachment: sectors.tiff>>
_______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user