Get the history of an account's tokens

def namedb_get_account_history(cur, address, offset=None, count=None):
    """
    Get the history of an account's tokens
    """
    sql = 'SELECT * FROM accounts WHERE address = ? ORDER BY block_id DESC, vtxindex DESC'
    args = (address,)

    if count is not None:
        sql += ' LIMIT ?'
        args += (count,)

    if offset is not None:
        sql += ' OFFSET ?'
        args += (offset,)

    sql += ';'
    rows = namedb_query_execute(cur, sql, args)

    ret = []
    for rowdata in rows:
        tmp = {}
        tmp.update(rowdata)
        ret.append(tmp)

    return ret