本文整理匯總了Python中sqlalchemy.select._limit_clause方法的典型用法代碼示例。如果您正苦於以下問題:Python select._limit_clause方法的具體用法?Python select._limit_clause怎麽用?Python select._limit_clause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.select
的用法示例。
在下文中一共展示了select._limit_clause方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_select_precolumns
# 需要導入模塊: from sqlalchemy import select [as 別名]
# 或者: from sqlalchemy.select import _limit_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 _limit_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 _limit_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 ""