My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 57: Unable to insert pyodbc Rows
1 person starred this issue and may be notified of changes. Back to list
Status:  Complete
Owner:  ----
Closed:  Dec 2009


 
Reported by isto...@gmail.com, Jun 24, 2009
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
Thanks.  This is a fantastic idea, but had never designed it to work -- it just 
happened to.  I've fixed this in commit 10ac782c60f8aa92c401963ca363d20f03de0a3e 
which will be in 2.1.7.  I've also added 2 SQL Server unit tests for this.


Status: Started
Dec 31, 2009
Project Member #2 mkleehammer
(No comment was entered for this change.)
Status: Verified
Nov 21, 2010
Project Member #3 mkleehammer
(No comment was entered for this change.)
Status: Complete

Powered by Google Project Hosting