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


Python operators.eq方法代码示例

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


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

示例1: test_composed

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def test_composed(self):
        a, b, e, f, q, j, r = (
            column("a"),
            column("b"),
            column("e"),
            column("f"),
            column("q"),
            column("j"),
            column("r"),
        )
        expr = and_((a + b) == q + func.sum(e + f), and_(j == r, f == q))
        self._assert_traversal(
            expr,
            [
                (operators.eq, a, q),
                (operators.eq, a, e),
                (operators.eq, a, f),
                (operators.eq, b, q),
                (operators.eq, b, e),
                (operators.eq, b, f),
                (operators.eq, j, r),
                (operators.eq, f, q),
            ],
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:26,代码来源:test_external_traversal.py

示例2: _get_nonansi_join_whereclause

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def _get_nonansi_join_whereclause(self, froms):
        clauses = []

        def visit_join(join):
            if join.isouter:
                def visit_binary(binary):
                    if binary.operator == sql_operators.eq:
                        if join.right.is_derived_from(binary.left.table):
                            binary.left = _OuterJoinColumn(binary.left)
                        elif join.right.is_derived_from(binary.right.table):
                            binary.right = _OuterJoinColumn(binary.right)
                clauses.append(visitors.cloned_traverse(
                    join.onclause, {}, {'binary': visit_binary}))
            else:
                clauses.append(join.onclause)

            for j in join.left, join.right:
                if isinstance(j, expression.Join):
                    visit_join(j)
                elif isinstance(j, expression.FromGrouping):
                    visit_join(j.element)

        for f in froms:
            if isinstance(f, expression.Join):
                visit_join(f)

        if not clauses:
            return None
        else:
            return sql.and_(*clauses) 
开发者ID:jpush,项目名称:jbox,代码行数:32,代码来源:base.py

示例3: __init__

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def __init__(self, left, right, operator=operators.eq):
        self.type = sqltypes.Boolean()
        self.left = expression._literal_as_binds(left)
        self.right = right
        self.operator = operator 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:base.py

示例4: any

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def any(self, other, operator=operators.eq):
            """Return ``other operator ANY (array)`` clause.

            Argument places are switched, because ANY requires array
            expression to be on the right hand-side.

            E.g.::

                from sqlalchemy.sql import operators

                conn.execute(
                    select([table.c.data]).where(
                            table.c.data.any(7, operator=operators.lt)
                        )
                )

            :param other: expression to be compared
            :param operator: an operator object from the
             :mod:`sqlalchemy.sql.operators`
             package, defaults to :func:`.operators.eq`.

            .. seealso::

                :class:`.postgresql.Any`

                :meth:`.postgresql.ARRAY.Comparator.all`

            """
            return Any(other, self.expr, operator=operator) 
开发者ID:jpush,项目名称:jbox,代码行数:31,代码来源:base.py

示例5: all

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def all(self, other, operator=operators.eq):
            """Return ``other operator ALL (array)`` clause.

            Argument places are switched, because ALL requires array
            expression to be on the right hand-side.

            E.g.::

                from sqlalchemy.sql import operators

                conn.execute(
                    select([table.c.data]).where(
                            table.c.data.all(7, operator=operators.lt)
                        )
                )

            :param other: expression to be compared
            :param operator: an operator object from the
             :mod:`sqlalchemy.sql.operators`
             package, defaults to :func:`.operators.eq`.

            .. seealso::

                :class:`.postgresql.All`

                :meth:`.postgresql.ARRAY.Comparator.any`

            """
            return All(other, self.expr, operator=operator) 
开发者ID:jpush,项目名称:jbox,代码行数:31,代码来源:base.py

示例6: any

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def any(self, elements, other, operator=None):
            """Return ``other operator ANY (array)`` clause.

            Argument places are switched, because ANY requires array
            expression to be on the right hand-side.

            E.g.::

                from sqlalchemy.sql import operators

                conn.execute(
                    select([table.c.data]).where(
                            table.c.data.any(7, operator=operators.lt)
                        )
                )

            :param other: expression to be compared
            :param operator: an operator object from the
             :mod:`sqlalchemy.sql.operators`
             package, defaults to :func:`.operators.eq`.

            .. seealso::

                :func:`.sql.expression.any_`

                :meth:`.types.ARRAY.Comparator.all`

            """
            operator = operator if operator else operators.eq
            return operator(
                elements._literal_as_binds(other),
                elements.CollectionAggregate._create_any(self.expr)
            ) 
开发者ID:yfauser,项目名称:planespotter,代码行数:35,代码来源:sqltypes.py

示例7: all

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def all(self, elements, other, operator=None):
            """Return ``other operator ALL (array)`` clause.

            Argument places are switched, because ALL requires array
            expression to be on the right hand-side.

            E.g.::

                from sqlalchemy.sql import operators

                conn.execute(
                    select([table.c.data]).where(
                            table.c.data.all(7, operator=operators.lt)
                        )
                )

            :param other: expression to be compared
            :param operator: an operator object from the
             :mod:`sqlalchemy.sql.operators`
             package, defaults to :func:`.operators.eq`.

            .. seealso::

                :func:`.sql.expression.all_`

                :meth:`.types.ARRAY.Comparator.any`

            """
            operator = operator if operator else operators.eq
            return operator(
                elements._literal_as_binds(other),
                elements.CollectionAggregate._create_all(self.expr)
            ) 
开发者ID:yfauser,项目名称:planespotter,代码行数:35,代码来源:sqltypes.py

示例8: __eq__

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def __eq__(self, other):
        """Implement the ``==`` operator.

        In a column context, produces the clause ``a = b``.
        If the target is ``None``, produces ``a IS NULL``.

        """
        return self.operate(eq, other) 
开发者ID:yfauser,项目名称:planespotter,代码行数:10,代码来源:operators.py

示例9: query_chooser

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def query_chooser(query):
    """query chooser.

    this also returns a list of shard ids, which can
    just be all of them.  but here we'll search into the Query in order
    to try to narrow down the list of shards to query.

    """
    ids = []

    # we'll grab continent names as we find them
    # and convert to shard ids
    for column, operator, value in _get_query_comparisons(query):
        # "shares_lineage()" returns True if both columns refer to the same
        # statement column, adjusting for any annotations present.
        # (an annotation is an internal clone of a Column object
        # and occur when using ORM-mapped attributes like
        # "WeatherLocation.continent"). A simpler comparison, though less
        # accurate, would be "column.key == 'continent'".
        if column.shares_lineage(WeatherLocation.__table__.c.continent):
            if operator == operators.eq:
                ids.append(shard_lookup[value])
            elif operator == operators.in_op:
                ids.extend(shard_lookup[v] for v in value)

    if len(ids) == 0:
        return ["north_america", "asia", "europe", "south_america"]
    else:
        return ids 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:31,代码来源:attribute_shard.py

示例10: any

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def any(self, other, operator=None):
            """Return ``other operator ANY (array)`` clause.

            Argument places are switched, because ANY requires array
            expression to be on the right hand-side.

            E.g.::

                from sqlalchemy.sql import operators

                conn.execute(
                    select([table.c.data]).where(
                            table.c.data.any(7, operator=operators.lt)
                        )
                )

            :param other: expression to be compared
            :param operator: an operator object from the
             :mod:`sqlalchemy.sql.operators`
             package, defaults to :func:`.operators.eq`.

            .. seealso::

                :func:`_expression.any_`

                :meth:`.types.ARRAY.Comparator.all`

            """
            elements = util.preloaded.sql_elements
            operator = operator if operator else operators.eq
            return operator(
                coercions.expect(roles.ExpressionElementRole, other),
                elements.CollectionAggregate._create_any(self.expr),
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:36,代码来源:sqltypes.py

示例11: all

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def all(self, other, operator=None):
            """Return ``other operator ALL (array)`` clause.

            Argument places are switched, because ALL requires array
            expression to be on the right hand-side.

            E.g.::

                from sqlalchemy.sql import operators

                conn.execute(
                    select([table.c.data]).where(
                            table.c.data.all(7, operator=operators.lt)
                        )
                )

            :param other: expression to be compared
            :param operator: an operator object from the
             :mod:`sqlalchemy.sql.operators`
             package, defaults to :func:`.operators.eq`.

            .. seealso::

                :func:`_expression.all_`

                :meth:`.types.ARRAY.Comparator.any`

            """
            elements = util.preloaded.sql_elements
            operator = operator if operator else operators.eq
            return operator(
                coercions.expect(roles.ExpressionElementRole, other),
                elements.CollectionAggregate._create_all(self.expr),
            ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:36,代码来源:sqltypes.py

示例12: test_basic

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def test_basic(self):
        a, b = column("a"), column("b")
        self._assert_traversal(a == b, [(operators.eq, a, b)]) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:5,代码来源:test_external_traversal.py

示例13: test_subquery

# 需要导入模块: from sqlalchemy.sql import operators [as 别名]
# 或者: from sqlalchemy.sql.operators import eq [as 别名]
def test_subquery(self):
        a, b, c = column("a"), column("b"), column("c")
        subq = select([c]).where(c == a).scalar_subquery()
        expr = and_(a == b, b == subq)
        self._assert_traversal(
            expr, [(operators.eq, a, b), (operators.eq, b, subq)]
        ) 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:9,代码来源:test_external_traversal.py


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