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


Python table.a方法代码示例

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


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

示例1: _offset_or_limit_clause_asint

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def _offset_or_limit_clause_asint(clause, attrname):
    """Convert the "offset or limit" clause of a select construct to an
    integer.

    This is only possible if the value is stored as a simple bound parameter.
    Otherwise, a compilation error is raised.

    """
    if clause is None:
        return None
    try:
        value = clause._limit_offset_value
    except AttributeError:
        raise exc.CompileError(
            "This SELECT structure does not use a simple "
            "integer value for %s" % attrname)
    else:
        return util.asint(value) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:20,代码来源:selectable.py

示例2: select

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def select(self, whereclause=None, **kwargs):
        """Create a :class:`.Select` from this :class:`.Join`.

        The equivalent long-hand form, given a :class:`.Join` object
        ``j``, is::

            from sqlalchemy import select
            j = select([j.left, j.right], **kw).\\
                        where(whereclause).\\
                        select_from(j)

        :param whereclause: the WHERE criterion that will be sent to
          the :func:`select()` function

        :param \**kwargs: all other kwargs are sent to the
          underlying :func:`select()` function.

        """
        collist = [self.left, self.right]

        return Select(collist, whereclause, from_obj=[self], **kwargs) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:23,代码来源:selectable.py

示例3: limit

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def limit(self, limit):
        """return a new selectable with the given LIMIT criterion
        applied.

        This is a numerical value which usually renders as a ``LIMIT``
        expression in the resulting select.  Backends that don't
        support ``LIMIT`` will attempt to provide similar
        functionality.

        .. versionchanged:: 1.0.0 - :meth:`.Select.limit` can now
           accept arbitrary SQL expressions as well as integer values.

        :param limit: an integer LIMIT parameter, or a SQL expression
         that provides an integer result.

        """

        self._limit_clause = _offset_or_limit_clause(limit) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:20,代码来源:selectable.py

示例4: offset

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def offset(self, offset):
        """return a new selectable with the given OFFSET criterion
        applied.


        This is a numeric value which usually renders as an ``OFFSET``
        expression in the resulting select.  Backends that don't
        support ``OFFSET`` will attempt to provide similar
        functionality.


        .. versionchanged:: 1.0.0 - :meth:`.Select.offset` can now
           accept arbitrary SQL expressions as well as integer values.

        :param offset: an integer OFFSET parameter, or a SQL expression
         that provides an integer result.

        """

        self._offset_clause = _offset_or_limit_clause(offset) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:22,代码来源:selectable.py

示例5: _create_union_all

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def _create_union_all(cls, *selects, **kwargs):
        """Return a ``UNION ALL`` of multiple selectables.

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

        A similar :func:`union_all()` method is available on all
        :class:`.FromClause` subclasses.

        \*selects
          a list of :class:`.Select` instances.

        \**kwargs
          available keyword arguments are the same as those of
          :func:`select`.

        """
        return CompoundSelect(CompoundSelect.UNION_ALL, *selects, **kwargs) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:20,代码来源:selectable.py

示例6: _create_intersect_all

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def _create_intersect_all(cls, *selects, **kwargs):
        """Return an ``INTERSECT ALL`` of multiple selectables.

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

        \*selects
          a list of :class:`.Select` instances.

        \**kwargs
          available keyword arguments are the same as those of
          :func:`select`.

        """
        return CompoundSelect(
            CompoundSelect.INTERSECT_ALL, *selects, **kwargs) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:18,代码来源:selectable.py

示例7: _froms

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def _froms(self):
        # would love to cache this,
        # but there's just enough edge cases, particularly now that
        # declarative encourages construction of SQL expressions
        # without tables present, to just regen this each time.
        froms = []
        seen = set()
        translate = self._from_cloned

        for item in itertools.chain(
            _from_objects(*self._raw_columns),
            _from_objects(self._whereclause)
            if self._whereclause is not None else (),
            self._from_obj
        ):
            if item is self:
                raise exc.InvalidRequestError(
                    "select() construct refers to itself as a FROM")
            if translate and item in translate:
                item = translate[item]
            if not seen.intersection(item._cloned_set):
                froms.append(item)
            seen.update(item._cloned_set)

        return froms 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:27,代码来源:selectable.py

示例8: with_statement_hint

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def with_statement_hint(self, text, dialect_name='*'):
        """add a statement hint to this :class:`.Select`.

        This method is similar to :meth:`.Select.with_hint` except that
        it does not require an individual table, and instead applies to the
        statement as a whole.

        Hints here are specific to the backend database and may include
        directives such as isolation levels, file directives, fetch directives,
        etc.

        .. versionadded:: 1.0.0

        .. seealso::

            :meth:`.Select.with_hint`

        """
        return self.with_hint(None, text, dialect_name) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:21,代码来源:selectable.py

示例9: distinct

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def distinct(self, *expr):
        """Return a new select() construct which will apply DISTINCT to its
        columns clause.

        :param \*expr: optional column expressions.  When present,
         the Postgresql dialect will render a ``DISTINCT ON (<expressions>>)``
         construct.

        """
        if expr:
            expr = [_literal_as_label_reference(e) for e in expr]
            if isinstance(self._distinct, list):
                self._distinct = self._distinct + expr
            else:
                self._distinct = expr
        else:
            self._distinct = True 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:19,代码来源:selectable.py

示例10: lateral

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def lateral(selectable, name=None):
    """Return a :class:`.Lateral` object.

    :class:`.Lateral` is an :class:`.Alias` subclass that represents
    a subquery with the LATERAL keyword applied to it.

    The special behavior of a LATERAL subquery is that it appears in the
    FROM clause of an enclosing SELECT, but may correlate to other
    FROM clauses of that SELECT.   It is a special case of subquery
    only supported by a small number of backends, currently more recent
    PostgreSQL versions.

    .. versionadded:: 1.1

    .. seealso::

        :ref:`lateral_selects` -  overview of usage.

    """
    return _interpret_as_from(selectable).lateral(name=name) 
开发者ID:Agentscreech,项目名称:ShelbySearch,代码行数:22,代码来源:selectable.py

示例11: subquery

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def subquery(alias, *args, **kwargs):
    """Return an :class:`.Alias` object derived
    from a :class:`.Select`.

    name
      alias name

    \*args, \**kwargs

      all other arguments are delivered to the
      :func:`select` function.

    """
    return Select(*args, **kwargs).alias(alias) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:16,代码来源:selectable.py

示例12: alias

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def alias(selectable, name=None, flat=False):
    """Return an :class:`.Alias` object.

    An :class:`.Alias` represents any :class:`.FromClause`
    with an alternate name assigned within SQL, typically using the ``AS``
    clause when generated, e.g. ``SELECT * FROM table AS aliasname``.

    Similar functionality is available via the
    :meth:`~.FromClause.alias` method
    available on all :class:`.FromClause` subclasses.

    When an :class:`.Alias` is created from a :class:`.Table` object,
    this has the effect of the table being rendered
    as ``tablename AS aliasname`` in a SELECT statement.

    For :func:`.select` objects, the effect is that of creating a named
    subquery, i.e. ``(select ...) AS aliasname``.

    The ``name`` parameter is optional, and provides the name
    to use in the rendered SQL.  If blank, an "anonymous" name
    will be deterministically generated at compile time.
    Deterministic means the name is guaranteed to be unique against
    other constructs used in the same statement, and will also be the
    same name for each successive compilation of the same statement
    object.

    :param selectable: any :class:`.FromClause` subclass,
        such as a table, select statement, etc.

    :param name: string name to be assigned as the alias.
        If ``None``, a name will be deterministically generated
        at compile time.

    :param flat: Will be passed through to if the given selectable
     is an instance of :class:`.Join` - see :meth:`.Join.alias`
     for details.

     .. versionadded:: 0.9.0

    """
    return selectable.alias(name=name, flat=flat) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:43,代码来源:selectable.py

示例13: suffix_with

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def suffix_with(self, *expr, **kw):
        """Add one or more expressions following the statement as a whole.

        This is used to support backend-specific suffix keywords on
        certain constructs.

        E.g.::

            stmt = select([col1, col2]).cte().suffix_with(
                "cycle empno set y_cycle to 1 default 0", dialect="oracle")

        Multiple suffixes can be specified by multiple calls
        to :meth:`.suffix_with`.

        :param \*expr: textual or :class:`.ClauseElement` construct which
         will be rendered following the target clause.
        :param \**kw: A single keyword 'dialect' is accepted.  This is an
         optional string dialect name which will
         limit rendering of this suffix to only that dialect.

        """
        dialect = kw.pop('dialect', None)
        if kw:
            raise exc.ArgumentError("Unsupported argument(s): %s" %
                                    ",".join(kw))
        self._setup_suffixes(expr, dialect) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:28,代码来源:selectable.py

示例14: count

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [as 别名]
def count(self, functions, whereclause=None, **params):
        """return a SELECT COUNT generated against this
        :class:`.FromClause`."""

        if self.primary_key:
            col = list(self.primary_key)[0]
        else:
            col = list(self.columns)[0]
        return Select(
            [functions.func.count(col).label('tbl_row_count')],
            whereclause,
            from_obj=[self],
            **params) 
开发者ID:sugarguo,项目名称:Flask_Blog,代码行数:15,代码来源:selectable.py

示例15: join

# 需要导入模块: from sqlalchemy import table [as 别名]
# 或者: from sqlalchemy.table import a [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


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