cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Neo4j Python - DB is updated, result summary is not null but the result object is None

Hi, I am trying to get the user id after inserting the node, but I dont see the value in the result object. Being new, I am confident I am missing something obvious. PL note that the node is in the db and the result summary object shows the nodes created. can you please help?

def insert_gdbuser(self, email_address, password):
    driver = NeoDB.get_session()
    user_id = uuid.uuid4()
    result = driver.write_transaction(
        lambda tx: tx.run(
            "CREATE (u:User {email_address:$email_address, password:$password, user_id:$user_id})"
            " RETURN u.email_address, u.user_id",
            {"email_address": str(email_address), "password": str(password), "user_id": str(user_id)}))

  
    record = result.single()

info = result.consume().counters.nodes_created
if info > 0 and record is not None:
print("The user id is", record["u.user_id"])

Thanks for your help

2 REPLIES 2

the result is no longer valid outside of the tx

so inside of the tx you need to return result.single()

thanks. figured it out from the docs after I submitted my question. Appreciate your response.