Opened 8 years ago

Closed 8 years ago

#4896 closed (fixed)

Buggy implementation of executemany for oracle

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

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@… 8 years ago.
Patch

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from adrian to mtredinnick
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

Changed 8 years ago by jdetaeye@…

Patch

comment:2 Changed 8 years ago by jdetaeye@…

  • 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 Changed 8 years ago by ikelly

  • Owner changed from nobody to ikelly
  • Status changed from new to assigned

comment:4 Changed 8 years ago by ikelly

  • Resolution set to fixed
  • Status changed from assigned to closed

(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