SQLITE3 + execute Insert -


this question has answer here:

trying execute insert item coming list:`

item=u'sunil goyal'

c.execute('''insert bpersons(person_name) values (?)''',item)`

is simple enough, returns

incorrect number of bindings supplied. current statement uses 1, , there 11 supplied.

clearly instead of reading item 1 element, reading characters. there no problem earlier code returns list:

>>> if meta[7]:#bcoz list empty     item in meta[7]:         print item 

sunil goyal

rehan yar khan

khan

kae capital

ashish shankar

karthik reddy

feroze azeez

len(meta[7]) 7

any idea going wrong?

insert looking iterable (documentation) , succeeds because unicode string iterable, should put inside of tuple or list handled sqlite3.

c.execute('''insert bpersons(person_name) values (?)''',(item,))` 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -