Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions google/cloud/spanner_dbapi/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def connect(
pool=None,
user_agent=None,
client=None,
route_to_leader_enabled=True,
route_to_leader_enabled=False,
):
"""Creates a connection to a Google Cloud Spanner database.

Expand Down Expand Up @@ -547,9 +547,11 @@ def connect(

:type route_to_leader_enabled: boolean
:param route_to_leader_enabled:
(Optional) Default True. Set route_to_leader_enabled as False to
(Optional) Default False. Set route_to_leader_enabled as False to
disable leader aware routing. Disabling leader aware routing would
route all requests in RW/PDML transactions to the closest region.
Inline Begin Transaction should be enabled to take advantage of the
the option.


:rtype: :class:`google.cloud.spanner_dbapi.connection.Connection`
Expand All @@ -567,14 +569,14 @@ def connect(
credentials,
project=project,
client_info=client_info,
route_to_leader_enabled=True,
route_to_leader_enabled=route_to_leader_enabled,
)
else:
client = spanner.Client(
project=project,
credentials=credentials,
client_info=client_info,
route_to_leader_enabled=True,
route_to_leader_enabled=route_to_leader_enabled,
)
else:
if project is not None and client.project != project:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/spanner_dbapi/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_w_explicit(self, mock_client):
project=PROJECT,
credentials=credentials,
client_info=mock.ANY,
route_to_leader_enabled=True,
route_to_leader_enabled=False,
)
client_info = mock_client.call_args_list[0][1]["client_info"]
self.assertEqual(client_info.user_agent, USER_AGENT)
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_w_credential_file_path(self, mock_client):
credentials_path,
project=PROJECT,
client_info=mock.ANY,
route_to_leader_enabled=True,
route_to_leader_enabled=False,
)
client_info = factory.call_args_list[0][1]["client_info"]
self.assertEqual(client_info.user_agent, USER_AGENT)
Expand Down