MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / select_from

Method select_from

lib/sqlalchemy/sql/selectable.py:6300–6340  ·  view source on GitHub ↗

r"""Return a new :func:`_expression.select` construct with the given FROM expression(s) merged into its list of FROM objects. E.g.:: table1 = table("t1", column("a")) table2 = table("t2", column("b")) s = select(table1.c.a).select_from(

(self, *froms: _FromClauseArgument)

Source from the content-addressed store, hash-verified

6298
6299 @_generative
6300 def select_from(self, *froms: _FromClauseArgument) -> Self:
6301 r"""Return a new :func:`_expression.select` construct with the
6302 given FROM expression(s)
6303 merged into its list of FROM objects.
6304
6305 E.g.::
6306
6307 table1 = table("t1", column("a"))
6308 table2 = table("t2", column("b"))
6309 s = select(table1.c.a).select_from(
6310 table1.join(table2, table1.c.a == table2.c.b)
6311 )
6312
6313 The "from" list is a unique set on the identity of each element,
6314 so adding an already present :class:`_schema.Table`
6315 or other selectable
6316 will have no effect. Passing a :class:`_expression.Join` that refers
6317 to an already present :class:`_schema.Table`
6318 or other selectable will have
6319 the effect of concealing the presence of that selectable as
6320 an individual element in the rendered FROM list, instead
6321 rendering it into a JOIN clause.
6322
6323 While the typical purpose of :meth:`_expression.Select.select_from`
6324 is to
6325 replace the default, derived FROM clause with a join, it can
6326 also be called with individual table elements, multiple times
6327 if desired, in the case that the FROM clause cannot be fully
6328 derived from the columns clause::
6329
6330 select(func.count("*")).select_from(table1)
6331
6332 """
6333
6334 self._from_obj += tuple(
6335 coercions.expect(
6336 roles.FromClauseRole, fromclause, apply_propagate_attrs=self
6337 )
6338 for fromclause in froms
6339 )
6340 return self
6341
6342 @_generative
6343 def correlate(

Callers 2

selectMethod · 0.45
select_fromMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected