Skip to content

Instantly share code, notes, and snippets.

@chrismaddalena
Created April 15, 2019 13:57
Show Gist options
  • Save chrismaddalena/351ed4ce1ccca4a12e3743488be4d293 to your computer and use it in GitHub Desktop.
Save chrismaddalena/351ed4ce1ccca4a12e3743488be4d293 to your computer and use it in GitHub Desktop.
def execute_query(driver, user, enabled=True):
"""Execute the provided query using the current Neo4j database connection."""
if enabled:
query = """
MATCH (u:User)
WHERE u.name =~ UPPER('%s@.*') AND (u.enabled = True)
RETURN u.enabled, u.pwdlastset, u.domain
""" % user
else:
query = """
MATCH (u:User)
WHERE u.name =~ UPPER('%s@.*')
RETURN u.enabled, u.pwdlastset, u.domain
""" % user
with driver.session() as session:
results = session.run(query)
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment