executemany()
Verfasst: Donnerstag 3. August 2006, 14:07
Hallo,
ich habe ein Problem mit executemany() von pysqlite.
Ein direkt aus dem Usage-Guide entnommenes Beispiel funktioniert:
Ändere ich das aber ein wenig ab, bekomme ich die Fehlermeldung
Woran liegt das? Gibt es vielleicht irgendwo eine genaue Referenz, was ich executemany() als 2. Parameter übergeben darf?
ich habe ein Problem mit executemany() von pysqlite.
Ein direkt aus dem Usage-Guide entnommenes Beispiel funktioniert:
Code: Alles auswählen
from pysqlite2 import dbapi2 as sqlite
con = sqlite.connect("test")
cur = con.cursor()
newPeople = (
('Lebed' , 53),
('Zhirinovsky' , 57),
)
cur.executemany("insert into people (name_last, age) values (?, ?)", newPeople)
# The changes will not be saved unless the transaction is committed explicitly:
con.commit()
Mein geänderter Code:Traceback (most recent call last):
File "test.py", line 12, in ?
cur.executemany("insert into people (name_last) values (?)", newPeople)
pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 5 supplied.
Code: Alles auswählen
from pysqlite2 import dbapi2 as sqlite
con = sqlite.connect("test")
cur = con.cursor()
newPeople = (
('name1'),
('name2'),
)
cur.executemany("insert into people (name_last) values (?)", newPeople)
# The changes will not be saved unless the transaction is committed explicitly:
con.commit()