Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-14-2021 10:37 AM
For example:
with driver.session() as session:
model_exists = session.run("""CALL gds.beta.model.exists('nc-model') YIELD exists""")
for model_exist in model_exists:
model_exists = model_exist[0]
break
if model_exists:
print("Model exists, which have to be dropped first!")
session.run("""CALL gds.beta.model.drop('nc-model')""")
print('Model dropped.')
In this code, is there a better way to get the single bool value out from the session's query, instead of doing this:
for model_exist in model_exists:
model_exists = model_exist[0]
break
Solved! Go to Solution.
05-17-2021 01:37 PM
05-15-2021 01:17 PM
Hello @lingvisa
with driver.session() as session:
model_exists = session.run("CALL gds.beta.model.exists('nc-model') YIELD exists").single()[0]
if model_exists:
print("Model exists, which have to be dropped first!")
session.run("CALL gds.beta.model.drop('nc-model')")
print('Model dropped.')
Regards,
Cobra
05-17-2021 01:19 PM
@Cobra , I tested, if you simply use 'if model_exists' without using the for loop to extract the bool value, the if checking always returns true, which is incorrect. 'Model_exists' is a Result object, not a bool. Could you test it?
05-17-2021 01:37 PM
Did you see the single()[0]
at the end of the row?
All the sessions of the conference are now available online