Python sqlalchemy.select._offset_clause() Examples

The following are 9 code examples of sqlalchemy.select._offset_clause(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sqlalchemy.select , or try the search function .
Example #1
Source File: base.py    From sqlalchemy with MIT License 6 votes vote down vote up
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 
Example #2
Source File: base.py    From jbox with MIT License 5 votes vote down vote up
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 
Example #3
Source File: base.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #4
Source File: base.py    From planespotter with MIT License 5 votes vote down vote up
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 
Example #5
Source File: base.py    From pyRevit with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #6
Source File: base.py    From sqlalchemy with MIT License 5 votes vote down vote up
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 
Example #7
Source File: base.py    From sqlalchemy with MIT License 5 votes vote down vote up
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 "" 
Example #8
Source File: base.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #9
Source File: base.py    From android_universal with MIT License 5 votes vote down vote up
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