1

I need to insert list like this

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

so I unpack it and try to insert it into db

 a,b,c,d = list

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

but It returns this error

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

I tried even [list]

any help , thank

1 Answer 1

2

You have to match the exact signature of list here.

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'

One more option is to use itertools.chain

from itertools import chain
a, b, c, d = chain.from_iterable(lst)
# a -> '1'
# b -> '2'
# c -> '3'
# d -> '4'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.