| Issue 57: | Unable to insert pyodbc Rows | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
This example uses an SQLite3 memory databse, but I experience the same
issue with MS Access and MS SQL Server 2005:
import pyodbc
if __name__ == "__main__":
con = pyodbc.connect(r'DRIVER=SQLite3 ODBC Driver;Database=:memory:')
cur = con.cursor()
cur.execute("create table t (name text, id integer)")
params = [(u'A', 1), (u'B', 2)]
print type(params), params
cur.executemany("insert into t(name, id) values (?, ?)", params)
rows = cur.execute("select * from t").fetchall()
print type(rows), rows
cur.executemany("insert into t(name, id) values (?, ?)", rows)
What is the expected output? What do you see instead?
I expect it to insert the data from the pyodbc Row, and give the following
output (actual output from pyodbc 2.1.3):
<type 'list'> [(u'A', 1), (u'B', 2)]
<type 'list'> [(u'A', 1), (u'B', 2)]
<type 'list'> [(u'A', 1), (u'B', 2), (u'A', 1), (u'B', 2)]
It instead produces this traceback:
Traceback (most recent call last):
File "...\bug_maker.py", line 15, in <module>
cur.executemany("insert into t(name, id) values (?, ?)", rows)
TypeError: ('Params must be in a list or tuple', 'HY000')
What version of the product are you using? On what operating system?
pydobc 2.1.6 with Python 2.6.2 official install on Windows XP Pro SP3 32-bit.
Please provide any additional information below.
This code works perfectly on pyodbc 2.1.3 prior to the patch for issue 45 .
Aug 7, 2009
Project Member
#1
mkleehammer
Status:
Started
Dec 31, 2009
(No comment was entered for this change.)
Status:
Verified
Nov 21, 2010
(No comment was entered for this change.)
Status:
Complete
|