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


Python select._offset_clause方法代码示例

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


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

示例1: get_select_precolumns

# 需要导入模块: from sqlalchemy import select [as 别名]
# 或者: from sqlalchemy.select import _offset_clause [as 别名]
def get_select_precolumns(self, select, **kw):
        """ MS-SQL puts TOP, it's version of LIMIT here """

        s = super(MSSQLCompiler, self).get_select_precolumns(select, **kw)

        if select._simple_int_limit and (
            select._offset_clause is None
            or (select._simple_int_offset and select._offset == 0)
        ):
            # ODBC drivers and possibly others
            # don't support bind params in the SELECT clause on SQL Server.
            # so have to use literal here.
            kw["literal_execute"] = True
            s += "TOP %s " % self.process(select._limit_clause, **kw)

        return s 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:18,代码来源:base.py

示例2: limit_clause

# 需要导入模块: from sqlalchemy import select [as 别名]
# 或者: from sqlalchemy.select import _offset_clause [as 别名]
def limit_clause(self, select, **kw):
        text = ""
        if select._limit_clause is not None:
            text += " \n LIMIT " + self.process(select._limit_clause, **kw)
        if select._offset_clause is not None:
            if select._limit_clause is None:
                text += " \n LIMIT ALL"
            text += " OFFSET " + self.process(select._offset_clause, **kw)
        return text 
开发者ID:jpush,项目名称:jbox,代码行数:11,代码来源:base.py

示例3: limit_clause

# 需要导入模块: from sqlalchemy import select [as 别名]
# 或者: from sqlalchemy.select import _offset_clause [as 别名]
def limit_clause(self, select, **kw):
        """ MSSQL 2012 supports OFFSET/FETCH operators
            Use it instead subquery with row_number

        """

        if self.dialect._supports_offset_fetch and (
            (not select._simple_int_limit and select._limit_clause is not None)
            or (
                select._offset_clause is not None
                and not select._simple_int_offset
                or select._offset
            )
        ):
            # OFFSET are FETCH are options of the ORDER BY clause
            if not select._order_by_clause.clauses:
                raise exc.CompileError(
                    "MSSQL requires an order_by when "
                    "using an OFFSET or a non-simple "
                    "LIMIT clause"
                )

            text = ""

            if select._offset_clause is not None:
                offset_str = self.process(select._offset_clause, **kw)
            else:
                offset_str = "0"
            text += "\n OFFSET %s ROWS" % offset_str

            if select._limit_clause is not None:
                text += "\n FETCH NEXT %s ROWS ONLY " % self.process(
                    select._limit_clause, **kw
                )
            return text
        else:
            return "" 
开发者ID:sqlalchemy,项目名称:sqlalchemy,代码行数:39,代码来源:base.py


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