Opened 17 years ago

Closed 17 years ago

#4896 closed (fixed)

Buggy implementation of executemany for oracle

Reported by: jdetaeye@… Owned by: Erin Kelly
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: oracle executemany
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The following example shows the buggy implementation. The same example works fine with sqlite and postgresql.

cursor = connection.cursor()
cursor.execute('create table test (Field1 NUMBER(11),Field2 NUMBER(11))')
cursor.executemany('insert into test values (%s, %s)', [(i,i+1) for i in range(1,100)])

It returns the following error message:

  File "C:\packages\Python-2.5\lib\site-packages\django\db\backends\util.py", line 30, in executemany
    return self.cursor.executemany(sql, param_list)
  File "C:\packages\Python-2.5\lib\site-packages\django\db\backends\oracle\base.py", line 125, in executemany
    query, params = self._rewrite_args(query, params)
  File "C:\packages\Python-2.5\lib\site-packages\django\db\backends\oracle\base.py", line 101, in _rewrite_args
    query = smart_str(query, self.charset) % tuple(args)
  TypeError: not all arguments converted during string formatting

Attachments (1)

executemany_oracle_sqlite.patch (3.8 KB ) - added by jdetaeye@… 17 years ago.
Patch

Download all attachments as: .zip

Change History (5)

comment:1 by Malcolm Tredinnick, 17 years ago

Owner: changed from Adrian Holovaty to Malcolm Tredinnick
Triage Stage: UnreviewedAccepted

Whoops. My bad. I'll fix it when I get a moment.

by jdetaeye@…, 17 years ago

Patch

comment:2 by jdetaeye@…, 17 years ago

Has patch: set

Takes a while to find a moment... :-)
Here is a patch that fixes this issue, as well as ticket #4765 that reports a problem with executemany on sqlite.

comment:3 by Erin Kelly, 17 years ago

Owner: changed from nobody to Erin Kelly
Status: newassigned

comment:4 by Erin Kelly, 17 years ago

Resolution: fixed
Status: assignedclosed

(In [6218]) Fixed #4896: fixed #4765: Patch for cursor.executemany using oracle and
sqlite3. Thanks, jdetaeye@…

Note: See TracTickets for help on using tickets.
Back to Top