import sqlite3


def get_lineageos_stats(conn, limit):
    """Retrieves lineageos stats with a specified limit"""
    conn.row_factory = sqlite3.Row
    cur = conn.cursor()
    # selects all fields from table where the device / model contains - exact
    cur.execute(f'select rank, code, count from stats limit {limit};')
    # to keep it simple, just get the first record found
    data = cur.fetchall()
    cur.close()
    conn.row_factory = None
    return data