当前位置: 首页>>代码示例>>Python>>正文


Python column.key方法代码示例

本文整理汇总了Python中sqlalchemy.column.key方法的典型用法代码示例。如果您正苦于以下问题:Python column.key方法的具体用法?Python column.key怎么用?Python column.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlalchemy.column的用法示例。


在下文中一共展示了column.key方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_outerjoin

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def _create_outerjoin(cls, left, right, onclause=None):
        """Return an ``OUTER JOIN`` clause element.

        The returned object is an instance of :class:`.Join`.

        Similar functionality is also available via the
        :meth:`~.FromClause.outerjoin()` method on any
        :class:`.FromClause`.

        :param left: The left side of the join.

        :param right: The right side of the join.

        :param onclause:  Optional criterion for the ``ON`` clause, is
          derived from foreign key relationships established between
          left and right otherwise.

        To chain joins together, use the :meth:`.FromClause.join` or
        :meth:`.FromClause.outerjoin` methods on the resulting
        :class:`.Join` object.

        """
        return cls(left, right, onclause, isouter=True) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:25,代码来源:selectable.py

示例2: _populate_column_collection

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def _populate_column_collection(self):
        for name, c in self._columns_plus_names:
            if not hasattr(c, '_make_proxy'):
                continue
            if name is None:
                key = None
            elif self.use_labels:
                key = c._key_label
                if key is not None and key in self.c:
                    key = c.anon_label
            else:
                key = None

            c._make_proxy(self, key=key,
                          name=name,
                          name_is_truncatable=True) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:18,代码来源:selectable.py

示例3: _populate_column_collection

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def _populate_column_collection(self):
        for cols in zip(*[s.c._all_columns for s in self.selects]):

            # this is a slightly hacky thing - the union exports a
            # column that resembles just that of the *first* selectable.
            # to get at a "composite" column, particularly foreign keys,
            # you have to dig through the proxies collection which we
            # generate below.  We may want to improve upon this, such as
            # perhaps _make_proxy can accept a list of other columns
            # that are "shared" - schema.column can then copy all the
            # ForeignKeys in. this would allow the union() to have all
            # those fks too.

            proxy = cols[0]._make_proxy(
                self, name=cols[0]._label if self.use_labels else None,
                key=cols[0]._key_label if self.use_labels else None)

            # hand-construct the "_proxies" collection to include all
            # derived columns place a 'weight' annotation corresponding
            # to how low in the list of select()s the column occurs, so
            # that the corresponding_column() operation can resolve
            # conflicts

            proxy._proxies = [
                c._annotate({'weight': i + 1}) for (i, c) in enumerate(cols)] 
开发者ID:Agentscreech,项目名称:ShelbySearch,代码行数:27,代码来源:selectable.py

示例4: join

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def join(self, right, onclause=None, isouter=False):
        """Return a :class:`.Join` from this :class:`.FromClause`
        to another :class:`FromClause`.

        E.g.::

            from sqlalchemy import join

            j = user_table.join(address_table,
                            user_table.c.id == address_table.c.user_id)
            stmt = select([user_table]).select_from(j)

        would emit SQL along the lines of::

            SELECT user.id, user.name FROM user
            JOIN address ON user.id = address.user_id

        :param right: the right side of the join; this is any
         :class:`.FromClause` object such as a :class:`.Table` object, and
         may also be a selectable-compatible object such as an ORM-mapped
         class.

        :param onclause: a SQL expression representing the ON clause of the
         join.  If left at ``None``, :meth:`.FromClause.join` will attempt to
         join the two tables based on a foreign key relationship.

        :param isouter: if True, render a LEFT OUTER JOIN, instead of JOIN.

        .. seealso::

            :func:`.join` - standalone function

            :class:`.Join` - the type of object produced

        """

        return Join(self, right, onclause, isouter) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:39,代码来源:selectable.py

示例5: outerjoin

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def outerjoin(self, right, onclause=None):
        """Return a :class:`.Join` from this :class:`.FromClause`
        to another :class:`FromClause`, with the "isouter" flag set to
        True.

        E.g.::

            from sqlalchemy import outerjoin

            j = user_table.outerjoin(address_table,
                            user_table.c.id == address_table.c.user_id)

        The above is equivalent to::

            j = user_table.join(
                address_table,
                user_table.c.id == address_table.c.user_id,
                isouter=True)

        :param right: the right side of the join; this is any
         :class:`.FromClause` object such as a :class:`.Table` object, and
         may also be a selectable-compatible object such as an ORM-mapped
         class.

        :param onclause: a SQL expression representing the ON clause of the
         join.  If left at ``None``, :meth:`.FromClause.join` will attempt to
         join the two tables based on a foreign key relationship.

        .. seealso::

            :meth:`.FromClause.join`

            :class:`.Join`

        """

        return Join(self, right, onclause, True) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:39,代码来源:selectable.py

示例6: primary_key

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def primary_key(self):
        """Return the collection of Column objects which comprise the
        primary key of this FromClause."""

        self._init_collections()
        self._populate_column_collection()
        return self.primary_key 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:9,代码来源:selectable.py

示例7: _refresh_for_new_column

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def _refresh_for_new_column(self, column):
        """Given a column added to the .c collection of an underlying
        selectable, produce the local version of that column, assuming this
        selectable ultimately should proxy this column.

        this is used to "ping" a derived selectable to add a new column
        to its .c. collection when a Column has been added to one of the
        Table objects it ultimtely derives from.

        If the given selectable hasn't populated its .c. collection yet,
        it should at least pass on the message to the contained selectables,
        but it will return None.

        This method is currently used by Declarative to allow Table
        columns to be added to a partially constructed inheritance
        mapping that may have already produced joins.  The method
        isn't public right now, as the full span of implications
        and/or caveats aren't yet clear.

        It's also possible that this functionality could be invoked by
        default via an event, which would require that
        selectables maintain a weak referencing collection of all
        derivations.

        """
        if not self._cols_populated:
            return None
        elif (column.key in self.columns and
              self.columns[column.key] is column):
            return column
        else:
            return None 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:34,代码来源:selectable.py

示例8: _joincond_trim_constraints

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def _joincond_trim_constraints(
            cls, a, b, constraints, consider_as_foreign_keys):
        # more than one constraint matched.  narrow down the list
        # to include just those FKCs that match exactly to
        # "consider_as_foreign_keys".
        if consider_as_foreign_keys:
            for const in list(constraints):
                if set(f.parent for f in const.elements) != set(
                        consider_as_foreign_keys):
                    del constraints[const]

        # if still multiple constraints, but
        # they all refer to the exact same end result, use it.
        if len(constraints) > 1:
            dedupe = set(tuple(crit) for crit in constraints.values())
            if len(dedupe) == 1:
                key = list(constraints)[0]
                constraints = {key: constraints[key]}

        if len(constraints) != 1:
            raise exc.AmbiguousForeignKeysError(
                "Can't determine join between '%s' and '%s'; "
                "tables have more than one foreign key "
                "constraint relationship between them. "
                "Please specify the 'onclause' of this "
                "join explicitly." % (a.description, b.description)) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:28,代码来源:selectable.py

示例9: append_column

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def append_column(self, c):
        self._columns[c.key] = c
        c.table = self 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:5,代码来源:selectable.py

示例10: _label_resolve_dict

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def _label_resolve_dict(self):
        d = dict(
            (c.key, c) for c in self.c
        )
        return d, d 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:7,代码来源:selectable.py

示例11: reduce_columns

# 需要导入模块: from sqlalchemy import column [as 别名]
# 或者: from sqlalchemy.column import key [as 别名]
def reduce_columns(self, sqlutil, only_synonyms=True):
        """Return a new :func`.select` construct with redundantly
        named, equivalently-valued columns removed from the columns clause.

        "Redundant" here means two columns where one refers to the
        other either based on foreign key, or via a simple equality
        comparison in the WHERE clause of the statement.   The primary purpose
        of this method is to automatically construct a select statement
        with all uniquely-named columns, without the need to use
        table-qualified labels as :meth:`.apply_labels` does.

        When columns are omitted based on foreign key, the referred-to
        column is the one that's kept.  When columns are omitted based on
        WHERE eqivalence, the first column in the columns clause is the
        one that's kept.

        :param only_synonyms: when True, limit the removal of columns
         to those which have the same name as the equivalent.   Otherwise,
         all columns that are equivalent to another are removed.

        .. versionadded:: 0.8

        """
        return self.with_only_columns(
            sqlutil.reduce_columns(
                self.inner_columns,
                only_synonyms=only_synonyms,
                *(self._whereclause, ) + tuple(self._from_obj)
            )
        ) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:32,代码来源:selectable.py


注:本文中的sqlalchemy.column.key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。