MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / set_shard

Method set_shard

lib/sqlalchemy/ext/horizontal_shard.py:122–134  ·  view source on GitHub ↗

Return a new query, limited to a single shard ID. All subsequent operations with the returned query will be against the single shard regardless of other state. The shard_id can be passed for a 2.0 style execution to the bind_arguments dictionary of :meth:`.Session.e

(self, shard_id: ShardIdentifier)

Source from the content-addressed store, hash-verified

120 self._shard_id = None
121
122 def set_shard(self, shard_id: ShardIdentifier) -> Self:
123 """Return a new query, limited to a single shard ID.
124
125 All subsequent operations with the returned query will
126 be against the single shard regardless of other state.
127
128 The shard_id can be passed for a 2.0 style execution to the
129 bind_arguments dictionary of :meth:`.Session.execute`::
130
131 results = session.execute(stmt, bind_arguments={"shard_id": "my_shard"})
132
133 """ # noqa: E501
134 return self.execution_options(_sa_shard_id=shard_id)
135
136
137class ShardedSession(Session):

Callers 7

test_shard_id_eventMethod · 0.80
test_refreshMethod · 0.80
test_deferredMethod · 0.80
test_unexpireMethod · 0.80

Calls 1

execution_optionsMethod · 0.45

Tested by 7

test_shard_id_eventMethod · 0.64
test_refreshMethod · 0.64
test_deferredMethod · 0.64
test_unexpireMethod · 0.64