當前位置: 首頁>>代碼示例>>Python>>正文


Python func.rank方法代碼示例

本文整理匯總了Python中sqlalchemy.func.rank方法的典型用法代碼示例。如果您正苦於以下問題:Python func.rank方法的具體用法?Python func.rank怎麽用?Python func.rank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlalchemy.func的用法示例。


在下文中一共展示了func.rank方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: over

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def over(self, partition_by=None, order_by=None):
        """Produce an OVER clause against this filtered function.

        Used against aggregate or so-called "window" functions,
        for database backends that support window functions.

        The expression::

            func.rank().filter(MyClass.y > 5).over(order_by='x')

        is shorthand for::

            from sqlalchemy import over, funcfilter
            over(funcfilter(func.rank(), MyClass.y > 5), order_by='x')

        See :func:`~.expression.over` for a full description.

        """
        return Over(self, partition_by=partition_by, order_by=order_by) 
開發者ID:jpush,項目名稱:jbox,代碼行數:21,代碼來源:elements.py

示例2: over

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def over(self, partition_by=None, order_by=None, range_=None, rows=None):
        """Produce an OVER clause against this filtered function.

        Used against aggregate or so-called "window" functions,
        for database backends that support window functions.

        The expression::

            func.rank().filter(MyClass.y > 5).over(order_by='x')

        is shorthand for::

            from sqlalchemy import over, funcfilter
            over(funcfilter(func.rank(), MyClass.y > 5), order_by='x')

        See :func:`_expression.over` for a full description.

        """
        return Over(
            self,
            partition_by=partition_by,
            order_by=order_by,
            range_=range_,
            rows=rows,
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:27,代碼來源:elements.py

示例3: over

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def over(self, partition_by=None, order_by=None, range_=None, rows=None):
        """Produce an OVER clause against this filtered function.

        Used against aggregate or so-called "window" functions,
        for database backends that support window functions.

        The expression::

            func.rank().filter(MyClass.y > 5).over(order_by='x')

        is shorthand for::

            from sqlalchemy import over, funcfilter
            over(funcfilter(func.rank(), MyClass.y > 5), order_by='x')

        See :func:`~.expression.over` for a full description.

        """
        return Over(
            self, partition_by=partition_by, order_by=order_by,
            range_=range_, rows=rows) 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:23,代碼來源:elements.py

示例4: __init__

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def __init__(self, element, *order_by):
        r"""Produce a :class:`.WithinGroup` object against a function.

        Used against so-called "ordered set aggregate" and "hypothetical
        set aggregate" functions, including :class:`.percentile_cont`,
        :class:`.rank`, :class:`.dense_rank`, etc.

        :func:`~.expression.within_group` is usually called using
        the :meth:`.FunctionElement.within_group` method, e.g.::

            from sqlalchemy import within_group
            stmt = select([
                department.c.id,
                func.percentile_cont(0.5).within_group(
                    department.c.salary.desc()
                )
            ])

        The above statement would produce SQL similar to
        ``SELECT department.id, percentile_cont(0.5)
        WITHIN GROUP (ORDER BY department.salary DESC)``.

        :param element: a :class:`.FunctionElement` construct, typically
         generated by :data:`~.expression.func`.
        :param \*order_by: one or more column elements that will be used
         as the ORDER BY clause of the WITHIN GROUP construct.

        .. versionadded:: 1.1

        .. seealso::

            :data:`.expression.func`

            :func:`.expression.over`

        """
        self.element = element
        if order_by is not None:
            self.order_by = ClauseList(
                *util.to_list(order_by),
                _literal_as_text=_literal_as_label_reference) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:43,代碼來源:elements.py

示例5: __init__

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def __init__(self, element, *order_by):
        r"""Produce a :class:`.WithinGroup` object against a function.

        Used against so-called "ordered set aggregate" and "hypothetical
        set aggregate" functions, including :class:`.percentile_cont`,
        :class:`.rank`, :class:`.dense_rank`, etc.

        :func:`_expression.within_group` is usually called using
        the :meth:`.FunctionElement.within_group` method, e.g.::

            from sqlalchemy import within_group
            stmt = select([
                department.c.id,
                func.percentile_cont(0.5).within_group(
                    department.c.salary.desc()
                )
            ])

        The above statement would produce SQL similar to
        ``SELECT department.id, percentile_cont(0.5)
        WITHIN GROUP (ORDER BY department.salary DESC)``.

        :param element: a :class:`.FunctionElement` construct, typically
         generated by :data:`~.expression.func`.
        :param \*order_by: one or more column elements that will be used
         as the ORDER BY clause of the WITHIN GROUP construct.

        .. versionadded:: 1.1

        .. seealso::

            :data:`.expression.func`

            :func:`_expression.over`

        """
        self.element = element
        if order_by is not None:
            self.order_by = ClauseList(
                *util.to_list(order_by), _literal_as_text_role=roles.ByOfRole
            ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:43,代碼來源:elements.py

示例6: test_no_paren_fns

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def test_no_paren_fns(self):
        for fn, expected in [
            (func.uid(), "uid"),
            (func.UID(), "UID"),
            (func.sysdate(), "sysdate"),
            (func.row_number(), "row_number()"),
            (func.rank(), "rank()"),
            (func.now(), "CURRENT_TIMESTAMP"),
            (func.current_timestamp(), "CURRENT_TIMESTAMP"),
            (func.user(), "USER"),
        ]:
            self.assert_compile(fn, expected) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:14,代碼來源:test_compiler.py

示例7: test_funcfilter_windowing_orderby

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def test_funcfilter_windowing_orderby(self):
        # test filtered windowing:
        self.assert_compile(
            select(
                [
                    func.rank()
                    .filter(table1.c.name > "foo")
                    .over(order_by=table1.c.name)
                ]
            ),
            "SELECT rank() FILTER (WHERE mytable.name > :name_1) "
            "OVER (ORDER BY mytable.name) AS anon_1 FROM mytable",
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:15,代碼來源:test_functions.py

示例8: test_funcfilter_windowing_orderby_partitionby

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def test_funcfilter_windowing_orderby_partitionby(self):
        self.assert_compile(
            select(
                [
                    func.rank()
                    .filter(table1.c.name > "foo")
                    .over(order_by=table1.c.name, partition_by=["description"])
                ]
            ),
            "SELECT rank() FILTER (WHERE mytable.name > :name_1) "
            "OVER (PARTITION BY mytable.description ORDER BY mytable.name) "
            "AS anon_1 FROM mytable",
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:15,代碼來源:test_functions.py

示例9: test_funcfilter_windowing_rows

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import rank [as 別名]
def test_funcfilter_windowing_rows(self):
        self.assert_compile(
            select(
                [
                    func.rank()
                    .filter(table1.c.name > "foo")
                    .over(rows=(1, 5), partition_by=["description"])
                ]
            ),
            "SELECT rank() FILTER (WHERE mytable.name > :name_1) "
            "OVER (PARTITION BY mytable.description ROWS BETWEEN :param_1 "
            "FOLLOWING AND :param_2 FOLLOWING) "
            "AS anon_1 FROM mytable",
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:16,代碼來源:test_functions.py


注:本文中的sqlalchemy.func.rank方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。