MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / select_from

Method select_from

lib/sqlalchemy/sql/selectable.py:6587–6627  ·  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

6585
6586 @_generative
6587 def select_from(self, *froms: _FromClauseArgument) -> Self:
6588 r"""Return a new :func:`_expression.select` construct with the
6589 given FROM expression(s)
6590 merged into its list of FROM objects.
6591
6592 E.g.::
6593
6594 table1 = table("t1", column("a"))
6595 table2 = table("t2", column("b"))
6596 s = select(table1.c.a).select_from(
6597 table1.join(table2, table1.c.a == table2.c.b)
6598 )
6599
6600 The "from" list is a unique set on the identity of each element,
6601 so adding an already present :class:`_schema.Table`
6602 or other selectable
6603 will have no effect. Passing a :class:`_expression.Join` that refers
6604 to an already present :class:`_schema.Table`
6605 or other selectable will have
6606 the effect of concealing the presence of that selectable as
6607 an individual element in the rendered FROM list, instead
6608 rendering it into a JOIN clause.
6609
6610 While the typical purpose of :meth:`_expression.Select.select_from`
6611 is to
6612 replace the default, derived FROM clause with a join, it can
6613 also be called with individual table elements, multiple times
6614 if desired, in the case that the FROM clause cannot be fully
6615 derived from the columns clause::
6616
6617 select(func.count("*")).select_from(table1)
6618
6619 """
6620
6621 self._from_obj += tuple(
6622 coercions.expect(
6623 roles.FromClauseRole, fromclause, apply_propagate_attrs=self
6624 )
6625 for fromclause in froms
6626 )
6627 return self
6628
6629 @_generative
6630 def correlate(

Callers 2

selectMethod · 0.45
select_fromMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected