Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.command(name="test_catalog_request")
- def test_catalog_request() -> None:
- """."""
- from neo4j import GraphDatabase
- import time
- config = Container.config
- neo4j_url = Container.neo4j_url
- print(neo4j_url) # neo4j://neo4j_live:7687
- auth = (config.neo4j.username(), config.neo4j.password())
- driver = GraphDatabase.driver(
- neo4j_url,
- auth=auth,
- database="neo4j",
- )
- full_text = """
- match (owner:User) - [:USER_CATALOGS] -> (catalog:Catalog)
- where ID(catalog)=$catalog_id
- return catalog
- """
- parameters = {'catalog_id': 1}
- t_start = time.monotonic()
- response = driver.execute_query(query_=full_text, parameters_=parameters)
- t_end = time.monotonic()
- print(response)
- '''
- EagerResult(records=[<Record catalog=<Node element_id='1' labels=frozenset({'Catalog'})
- properties={'is_public': 'true', 'description': 'My description',
- 'title': 'My Title'}>>],
- summary=<neo4j._work.summary.ResultSummary object at 0x7fe59f232440>,
- keys=['catalog'])
- '''
- time_diff = round(t_end - t_start, 3)
- print(f"Neo4j: Execute and return time: {time_diff} seconds") Neo4j: Execute and return time: 1.219 seconds
Advertisement
Add Comment
Please, Sign In to add comment