def GetLastRow(self):
    # We need the following sql (assuming a PRIMARY KEY (a,b,c)):
    # ORDER BY a DESC, b DESC, c DESC
    order_desc = []
    for c in self._table.GetPrimaryKey():
      order_desc.append('`%s` DESC' % c)

    attrs = self._attrs.copy()
    attrs['select'] = self._PrimaryKeyForSelect()
    attrs['order_by'] = ', '.join(order_desc)
    sql = ('SELECT %(select)s '
           'FROM %(db)s.%(table)s FORCE INDEX (PRIMARY) '
           'ORDER BY %(order_by)s LIMIT 1')

    res = self._dbh.ExecuteOrDie(sql % attrs)
    if res:
      return res[0]
Get the last row of a table (in PRIMARY KEY order).
dataset/ETHPy150Open google/mysql-tools/pylib/range_lib.py/PrimaryKeyRange.GetLastRow