Mapping result rows to namedtuple in python sqlite -
i playing bit python api sqlite3, have little table store languages id, name , creation_date fields. trying map raw query results namedtuple docs recommend, way can manage rows in more readable way, here namedtuple . languagerecord = namedtuple('languagerecord', 'id, name, creation_date') the code docs suggest mapping follows: for language in map(languagerecord._make, c.fetchall()): # languages this fine when want return collection of languages in case want retrieve 1 language: c.execute('select * language name=?', (name,)) so first attempt this: language = map(languagerecord._make, c.fetchone()) this code doesn't works because fetchone() returns tuple instead list 1 tuple, map function tries create 3 namedtuples 1 each tuple field thought. my first approach solve explicitly create list , append tuple result, like: languages = [] languages.append(c.fetchone()) language in map(languagerecord._make, languages): # language my s...