當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。