cycquery.ops.OrderByΒΆ

class OrderBy(cols, ascending=None)[source]ΒΆ

Bases: QueryOp

Order, or sort, the rows of a table by some columns.

Parameters:
  • cols (Union[str, List[str]]) – Columns by which to order.

  • ascending (Union[bool, List[bool], None]) – Whether to order each columns by ascending (True) or descending (False). If not provided, orders all by ascending.

Examples

>>> OrderBy("col1")(table)
>>> OrderBy(["col1", "col2"])(table)
>>> OrderBy(["col1", "col2"], [True, False])(table)
>>> OrderBy(["col1", "col2"], True)(table)

Methods

__call__(table)[source]ΒΆ

Process the table.

Parameters:

table (Union[Select, Subquery, Table, DBTable]) – Table on which to perform the operation.

Returns:

Processed table.

Return type:

sqlalchemy.sql.selectable.Subquery