Skip to content

Commit

Permalink
Fix API docs: params have trailing underscore now
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdedude committed Oct 28, 2022
1 parent bd8fcab commit a2b80f1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 56 deletions.
28 changes: 14 additions & 14 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,21 @@ Closing a driver will immediately shut down all connections in the pool.
The method is roughly equivalent to::

def execute_query(
query, parameters, routing, database, impersonated_user,
bookmark_manager, result_transformer,
query_, parameters_, routing_, database_, impersonated_user_,
bookmark_manager_, result_transformer_, **kwargs
):
def work(tx):
result = tx.run(query, parameters)
return some_transformer(result)
result = tx.run(query_, parameters_, **kwargs)
return result_transformer_(result)

with driver.session(
database=database,
impersonated_user=impersonated_user,
bookmark_manager=bookmark_manager,
database=database_,
impersonated_user=impersonated_user_,
bookmark_manager=bookmark_manager_,
) as session:
if routing == RoutingControl.WRITERS:
if routing_ == RoutingControl.WRITERS:
return session.execute_write(work)
elif routing == RoutingControl.READERS:
elif routing_ == RoutingControl.READERS:
return session.execute_read(work)

Usage example::
Expand All @@ -200,8 +200,8 @@ Closing a driver will immediately shut down all connections in the pool.
records, summary, keys = driver.execute_query(
"MATCH (p:Person {age: $age}) RETURN p.name",
{"age": 42},
routing=neo4j.RoutingControl.READERS, # or just "r"
database="neo4j",
routing_=neo4j.RoutingControl.READERS, # or just "r"
database_="neo4j",
)
assert keys == ["p.name"] # not needed, just for illustration
# log_summary(summary) # log some metadata
Expand All @@ -221,9 +221,9 @@ Closing a driver will immediately shut down all connections in the pool.
"SET p.nickname = 'My dear' "
"RETURN count(*)",
# optional routing parameter, as write is default
# routing=neo4j.RoutingControl.WRITERS, # or just "w",
database="neo4j",
result_transformer=neo4j.Result.single,
# routing_=neo4j.RoutingControl.WRITERS, # or just "w",
database_="neo4j",
result_transformer_=neo4j.Result.single,
)
assert record is not None # for typechecking and illustration
count = record[0]
Expand Down
28 changes: 14 additions & 14 deletions docs/source/async_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,21 @@ Closing a driver will immediately shut down all connections in the pool.
The method is roughly equivalent to::

async def execute_query(
query, parameters, routing, database, impersonated_user,
bookmark_manager, result_transformer,
query_, parameters_, routing_, database_, impersonated_user_,
bookmark_manager_, result_transformer_, **kwargs
):
async def work(tx):
result = await tx.run(query, parameters)
return await some_transformer(result)
result = await tx.run(query_, parameters_, **kwargs)
return await result_transformer_(result)

async with driver.session(
database=database,
impersonated_user=impersonated_user,
bookmark_manager=bookmark_manager,
database=database_,
impersonated_user=impersonated_user_,
bookmark_manager=bookmark_manager_,
) as session:
if routing == RoutingControl.WRITERS:
if routing_ == RoutingControl.WRITERS:
return await session.execute_write(work)
elif routing == RoutingControl.READERS:
elif routing_ == RoutingControl.READERS:
return await session.execute_read(work)

Usage example::
Expand All @@ -184,8 +184,8 @@ Closing a driver will immediately shut down all connections in the pool.
records, summary, keys = await driver.execute_query(
"MATCH (p:Person {age: $age}) RETURN p.name",
{"age": 42},
routing=neo4j.RoutingControl.READERS, # or just "r"
database="neo4j",
routing_=neo4j.RoutingControl.READERS, # or just "r"
database_="neo4j",
)
assert keys == ["p.name"] # not needed, just for illustration
# log_summary(summary) # log some metadata
Expand All @@ -205,9 +205,9 @@ Closing a driver will immediately shut down all connections in the pool.
"SET p.nickname = 'My dear' "
"RETURN count(*)",
# optional routing parameter, as write is default
# routing=neo4j.RoutingControl.WRITERS, # or just "w",
database="neo4j",
result_transformer=neo4j.AsyncResult.single,
# routing_=neo4j.RoutingControl.WRITERS, # or just "w",
database_="neo4j",
result_transformer_=neo4j.AsyncResult.single,
)
assert record is not None # for typechecking and illustration
count = record[0]
Expand Down
28 changes: 14 additions & 14 deletions neo4j/_async/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,21 +553,21 @@ async def execute_query(
The method is roughly equivalent to::
async def execute_query(
query, parameters, routing, database, impersonated_user,
bookmark_manager, result_transformer,
query_, parameters_, routing_, database_, impersonated_user_,
bookmark_manager_, result_transformer_, **kwargs
):
async def work(tx):
result = await tx.run(query, parameters)
return await some_transformer(result)
result = await tx.run(query_, parameters_, **kwargs)
return await result_transformer_(result)
async with driver.session(
database=database,
impersonated_user=impersonated_user,
bookmark_manager=bookmark_manager,
database=database_,
impersonated_user=impersonated_user_,
bookmark_manager=bookmark_manager_,
) as session:
if routing == RoutingControl.WRITERS:
if routing_ == RoutingControl.WRITERS:
return await session.execute_write(work)
elif routing == RoutingControl.READERS:
elif routing_ == RoutingControl.READERS:
return await session.execute_read(work)
Usage example::
Expand All @@ -582,8 +582,8 @@ async def example(driver: neo4j.AsyncDriver) -> List[str]:
records, summary, keys = await driver.execute_query(
"MATCH (p:Person {age: $age}) RETURN p.name",
{"age": 42},
routing=neo4j.RoutingControl.READERS, # or just "r"
database="neo4j",
routing_=neo4j.RoutingControl.READERS, # or just "r"
database_="neo4j",
)
assert keys == ["p.name"] # not needed, just for illustration
# log_summary(summary) # log some metadata
Expand All @@ -603,9 +603,9 @@ async def example(driver: neo4j.AsyncDriver) -> int:
"SET p.nickname = 'My dear' "
"RETURN count(*)",
# optional routing parameter, as write is default
# routing=neo4j.RoutingControl.WRITERS, # or just "w",
database="neo4j",
result_transformer=neo4j.AsyncResult.single,
# routing_=neo4j.RoutingControl.WRITERS, # or just "w",
database_="neo4j",
result_transformer_=neo4j.AsyncResult.single,
)
assert record is not None # for typechecking and illustration
count = record[0]
Expand Down
28 changes: 14 additions & 14 deletions neo4j/_sync/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,21 +552,21 @@ def execute_query(
The method is roughly equivalent to::
def execute_query(
query, parameters, routing, database, impersonated_user,
bookmark_manager, result_transformer,
query_, parameters_, routing_, database_, impersonated_user_,
bookmark_manager_, result_transformer_, **kwargs
):
def work(tx):
result = tx.run(query, parameters)
return some_transformer(result)
result = tx.run(query_, parameters_, **kwargs)
return result_transformer_(result)
with driver.session(
database=database,
impersonated_user=impersonated_user,
bookmark_manager=bookmark_manager,
database=database_,
impersonated_user=impersonated_user_,
bookmark_manager=bookmark_manager_,
) as session:
if routing == RoutingControl.WRITERS:
if routing_ == RoutingControl.WRITERS:
return session.execute_write(work)
elif routing == RoutingControl.READERS:
elif routing_ == RoutingControl.READERS:
return session.execute_read(work)
Usage example::
Expand All @@ -581,8 +581,8 @@ def example(driver: neo4j.Driver) -> List[str]:
records, summary, keys = driver.execute_query(
"MATCH (p:Person {age: $age}) RETURN p.name",
{"age": 42},
routing=neo4j.RoutingControl.READERS, # or just "r"
database="neo4j",
routing_=neo4j.RoutingControl.READERS, # or just "r"
database_="neo4j",
)
assert keys == ["p.name"] # not needed, just for illustration
# log_summary(summary) # log some metadata
Expand All @@ -602,9 +602,9 @@ def example(driver: neo4j.Driver) -> int:
"SET p.nickname = 'My dear' "
"RETURN count(*)",
# optional routing parameter, as write is default
# routing=neo4j.RoutingControl.WRITERS, # or just "w",
database="neo4j",
result_transformer=neo4j.Result.single,
# routing_=neo4j.RoutingControl.WRITERS, # or just "w",
database_="neo4j",
result_transformer_=neo4j.Result.single,
)
assert record is not None # for typechecking and illustration
count = record[0]
Expand Down

0 comments on commit a2b80f1

Please sign in to comment.