如何将多维列表插入sqlite db

How to insert multidimensional list into sqlite db

我需要像这样插入列表

 list = [['1'], ['2'], ['3'], ['4']]

所以我解压它并尝试将它插入 db

 a,b,c,d = list

 db.execute("INSERT INTO show (titolo,stagioni,clima,temperature) VALUES (?,?,?,?)",(a,b,c,d))
 db.commit()

但是returns这个错误

exception=InterfaceError('Error binding parameter 0 - probably unsupported type.')>

我什至试过了 [list]

任何帮助,谢谢

您必须在此处匹配列表的确切签名。

a, b, c, d = lst
# a -> ['1']
# b -> ['2']
# c -> ['3']
# d -> ['4']

([a], [b], [c], [d]) = lst
# a -> '1'
# b -> '2'
# c -> '3'
# d -> '4'

另一种选择是使用 itertools.chain

from itertools import chain
a, b, c, d = chain.from_iterable(lst)
# a -> '1'
# b -> '2'
# c -> '3'
# d -> '4'