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


Python func.bernoulli方法代碼示例

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


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

示例1: tablesample

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import bernoulli [as 別名]
def tablesample(selectable, sampling, name=None, seed=None):
    """Return a :class:`.TableSample` object.

    :class:`.TableSample` is an :class:`.Alias` subclass that represents
    a table with the TABLESAMPLE clause applied to it.
    :func:`~.expression.tablesample`
    is also available from the :class:`.FromClause` class via the
    :meth:`.FromClause.tablesample` method.

    The TABLESAMPLE clause allows selecting a randomly selected approximate
    percentage of rows from a table. It supports multiple sampling methods,
    most commonly BERNOULLI and SYSTEM.

    e.g.::

        from sqlalchemy import func

        selectable = people.tablesample(
                    func.bernoulli(1),
                    name='alias',
                    seed=func.random())
        stmt = select([selectable.c.people_id])

    Assuming ``people`` with a column ``people_id``, the above
    statement would render as::

        SELECT alias.people_id FROM
        people AS alias TABLESAMPLE bernoulli(:bernoulli_1)
        REPEATABLE (random())

    .. versionadded:: 1.1

    :param sampling: a ``float`` percentage between 0 and 100 or
        :class:`.functions.Function`.

    :param name: optional alias name

    :param seed: any real-valued SQL expression.  When specified, the
     REPEATABLE sub-clause is also rendered.

    """
    return _interpret_as_from(selectable).tablesample(
        sampling, name=name, seed=seed) 
開發者ID:yfauser,項目名稱:planespotter,代碼行數:45,代碼來源:selectable.py

示例2: _factory

# 需要導入模塊: from sqlalchemy import func [as 別名]
# 或者: from sqlalchemy.func import bernoulli [as 別名]
def _factory(cls, selectable, sampling, name=None, seed=None):
        """Return a :class:`_expression.TableSample` object.

        :class:`_expression.TableSample` is an :class:`_expression.Alias`
        subclass that represents
        a table with the TABLESAMPLE clause applied to it.
        :func:`_expression.tablesample`
        is also available from the :class:`_expression.FromClause`
        class via the
        :meth:`_expression.FromClause.tablesample` method.

        The TABLESAMPLE clause allows selecting a randomly selected approximate
        percentage of rows from a table. It supports multiple sampling methods,
        most commonly BERNOULLI and SYSTEM.

        e.g.::

            from sqlalchemy import func

            selectable = people.tablesample(
                        func.bernoulli(1),
                        name='alias',
                        seed=func.random())
            stmt = select([selectable.c.people_id])

        Assuming ``people`` with a column ``people_id``, the above
        statement would render as::

            SELECT alias.people_id FROM
            people AS alias TABLESAMPLE bernoulli(:bernoulli_1)
            REPEATABLE (random())

        .. versionadded:: 1.1

        :param sampling: a ``float`` percentage between 0 and 100 or
            :class:`_functions.Function`.

        :param name: optional alias name

        :param seed: any real-valued SQL expression.  When specified, the
         REPEATABLE sub-clause is also rendered.

        """
        return coercions.expect(roles.FromClauseRole, selectable).tablesample(
            sampling, name=name, seed=seed
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:48,代碼來源:selectable.py


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