Skip to content

Commit 17decbd

Browse files
author
Chris Turner
committed
add python-specific order/limit/offset docs parts
1 parent 3df05c0 commit 17decbd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs-parts/queries/03-Fetch_lang1.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ Primary key values
3535
3636
``KEY`` can also used when returning attribute values as separate variables, such that one of the returned variables contains the entire primary keys.
3737

38+
Sorting and limiting the results
39+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40+
41+
To sort the result, add the additional ``order_by`` argument to ``fetch`` .
42+
43+
.. code-block:: python
44+
45+
data = query.fetch(order_by='name')
46+
47+
The ``order_by`` argument is passed directly to SQL and follows the same syntax as the `ORDER BY clause <https://dev.mysql.com/doc/refman/5.7/en/order-by-optimization.html>`_
48+
49+
Similarly, the LIMIT and OFFSET clauses can be used to limit the result to a subset of entities.
50+
51+
For example, one could do the following:
52+
53+
.. code-block:: python
54+
55+
data = query.fetch(order_by='name', limit=10, offset=5)
56+
3857
Usage with Pandas
3958
~~~~~~~~~~~~~~~~~
4059

0 commit comments

Comments
 (0)