Mapping result rows to namedtuple in python sqlite

前端 未结 3 1132
说谎
说谎 2020-12-31 06:42

I am playing a bit with the python api for sqlite3, i have a little table for store languages with an id, name and creation_date fields. I am trying to map the raw query res

3条回答
  •  醉梦人生
    2020-12-31 06:55

    I think better to use for language in map(LanguageRecord._make, c.fetchall()[:1]): Because it can cause IndexError with fetchall()[0].

    If you need one result and there is already "WHERE" in query. As I understand query should return one row. Early optimization is evil. :)

提交回复
热议问题