Skip to content

Commit 7fe9204

Browse files
committed
re-generate sync driver
1 parent 5759926 commit 7fe9204

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

neo4j/_sync/driver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def do_cypher_tx(tx):
436436
records, _ = tx.query("RETURN 1 AS x")
437437
return records
438438
439-
values = driver.execute(do_cypher_tx,
439+
values = driver.execute(do_cypher_tx,
440440
database="neo4j",
441441
cluster_member_access=neo4j.api.CLUSTER_READERS_ACCESS)
442442
@@ -457,6 +457,7 @@ def get_two_tx(tx):
457457
# use the summary for logging etc.
458458
return values
459459
460+
460461
values = driver.execute(get_two_tx)
461462
462463
:param transaction_function: a function that takes a transaction as an

neo4j/_sync/io/_pool.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ def acquire(
351351
def is_direct(self):
352352
return True
353353

354+
354355
class Neo4jPool(IOPool):
355356
""" Connection pool with routing table.
356357
"""
@@ -399,9 +400,6 @@ def __init__(self, opener, pool_config, workspace_config, address):
399400
self.routing_tables = {workspace_config.database: RoutingTable(database=workspace_config.database, routers=[address])}
400401
self.refresh_lock = RLock()
401402

402-
def is_direct(self):
403-
return False
404-
405403
def __repr__(self):
406404
""" The representation shows the initial routing addresses.
407405
@@ -794,3 +792,6 @@ def on_write_failure(self, address):
794792
for database in self.routing_tables.keys():
795793
self.routing_tables[database].writers.discard(address)
796794
log.debug("[#0000] C: <ROUTING> table=%r", self.routing_tables)
795+
796+
def is_direct(self):
797+
return False

neo4j/_sync/work/result.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
# limitations under the License.
1717

1818

19-
from collections import deque
19+
from collections import (
20+
deque,
21+
namedtuple,
22+
)
2023
from warnings import warn
21-
from collections import namedtuple
2224

2325
from ..._async_compat.util import Util
2426
from ..._codec.hydration import BrokenHydrationObject
@@ -709,5 +711,4 @@ def closed(self):
709711
"""
710712
return self._out_of_scope or self._consumed
711713

712-
713714
QueryResult = namedtuple("QueryResult", ("records", "summary"))

neo4j/_sync/work/session.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
)
2929
from ...api import (
3030
Bookmarks,
31-
READ_ACCESS,
32-
WRITE_ACCESS,
3331
CLUSTER_AUTO_ACCESS,
3432
CLUSTER_READERS_ACCESS,
35-
CLUSTER_WRITERS_ACCESS
33+
CLUSTER_WRITERS_ACCESS,
34+
READ_ACCESS,
35+
WRITE_ACCESS,
3636
)
3737
from ...exceptions import (
3838
ClientError,
@@ -43,7 +43,10 @@
4343
TransactionError,
4444
)
4545
from ...work import Query
46-
from .result import QueryResult, Result
46+
from .result import (
47+
QueryResult,
48+
Result,
49+
)
4750
from .transaction import (
4851
ManagedTransaction,
4952
Transaction,
@@ -253,10 +256,11 @@ def query(self, query, parameters=None, **kwargs):
253256
:rtype: QueryResult
254257
"""
255258
skip_records = kwargs.pop("skip_records", False)
256-
259+
257260
def job(tx, **job_kwargs):
258261
if skip_records:
259-
summary = tx.run(query, parameters, **job_kwargs)
262+
result = tx.run(query, parameters, **job_kwargs)
263+
summary = result.consume()
260264
return QueryResult([], summary)
261265
return tx.query(query, parameters, **job_kwargs)
262266

@@ -291,7 +295,7 @@ def do_cypher_tx(tx):
291295
return records
292296
293297
with driver.session() as session:
294-
values = session.execute(do_cypher_tx,
298+
values = session.execute(do_cypher_tx,
295299
cluster_member_access=neo4j.api.CLUSTER_READERS_ACCESS)
296300
297301
Example::

neo4j/_sync/work/transaction.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
from ...exceptions import TransactionError
2323
from ...work import Query
2424
from ..io import ConnectionErrorHandler
25-
from .result import QueryResult, Result
25+
from .result import (
26+
QueryResult,
27+
Result,
28+
)
2629

2730

2831
__all__ = ("Transaction", "ManagedTransaction")
@@ -141,9 +144,9 @@ def query(self, query, parameters=None, **kwparameters):
141144
queries below are all equivalent::
142145
143146
>>> query = "CREATE (a:Person { name: $name, age: $age })"
144-
>>> query_result = tx.run(query, {"name": "Alice", "age": 33})
145-
>>> query_result = tx.run(query, {"name": "Alice"}, age=33)
146-
>>> query_result = tx.run(query, name="Alice", age=33)
147+
>>> query_result = tx.query(query, {"name": "Alice", "age": 33})
148+
>>> query_result = tx.query(query, {"name": "Alice"}, age=33)
149+
>>> query_result = tx.query(query, name="Alice", age=33)
147150
148151
Parameter values can be of any type supported by the Neo4j type
149152
system. In Python, this includes :class:`bool`, :class:`int`,
@@ -162,7 +165,9 @@ def query(self, query, parameters=None, **kwparameters):
162165
:raise TransactionError: if the transaction is already closed
163166
"""
164167
result = self.run(query, parameters, **kwparameters)
165-
records = list(result)
168+
records = []
169+
for x in result:
170+
records.append(x)
166171
summary = result.consume()
167172
return QueryResult(records, summary)
168173

0 commit comments

Comments
 (0)