本文整理汇总了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
示例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
示例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 ""