| 441 | | def _rewrite_args(self, query, params=None): |
|---|
| 442 | | if params is None: |
|---|
| 443 | | params = [] |
|---|
| 444 | | else: |
|---|
| 445 | | params = self._format_params(params) |
|---|
| 446 | | args = [(':arg%d' % i) for i in range(len(params))] |
|---|
| 447 | | query = smart_str(query, self.charset) % tuple(args) |
|---|
| 448 | | # cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it |
|---|
| 449 | | # it does want a trailing ';' but not a trailing '/'. However, these |
|---|
| 450 | | # characters must be included in the original query in case the query |
|---|
| 451 | | # is being passed to SQL*Plus. |
|---|
| 452 | | if query.endswith(';') or query.endswith('/'): |
|---|
| 453 | | query = query[:-1] |
|---|
| 454 | | return query, params |
|---|
| 455 | | |
|---|
| 467 | | query, params = self._rewrite_args(query, params) |
|---|
| | 452 | if params is None: |
|---|
| | 453 | params = [] |
|---|
| | 454 | else: |
|---|
| | 455 | params = self._format_params(params) |
|---|
| | 456 | args = [(':arg%d' % i) for i in range(len(params))] |
|---|
| | 457 | # cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it |
|---|
| | 458 | # it does want a trailing ';' but not a trailing '/'. However, these |
|---|
| | 459 | # characters must be included in the original query in case the query |
|---|
| | 460 | # is being passed to SQL*Plus. |
|---|
| | 461 | if query.endswith(';') or query.endswith('/'): |
|---|
| | 462 | query = query[:-1] |
|---|
| | 463 | query = smart_str(query, self.charset) % tuple(args) |
|---|
| 471 | | query, params = self._rewrite_args(query, params) |
|---|
| 472 | | return Database.Cursor.executemany(self, query, params) |
|---|
| | 467 | try: |
|---|
| | 468 | args = [(':arg%d' % i) for i in range(len(params[0]))] |
|---|
| | 469 | except (IndexError, TypeError): |
|---|
| | 470 | # No params given, nothing to do |
|---|
| | 471 | return None |
|---|
| | 472 | # cx_Oracle wants no trailing ';' for SQL statements. For PL/SQL, it |
|---|
| | 473 | # it does want a trailing ';' but not a trailing '/'. However, these |
|---|
| | 474 | # characters must be included in the original query in case the query |
|---|
| | 475 | # is being passed to SQL*Plus. |
|---|
| | 476 | if query.endswith(';') or query.endswith('/'): |
|---|
| | 477 | query = query[:-1] |
|---|
| | 478 | query = smart_str(query, self.charset) % tuple(args) |
|---|
| | 479 | new_param_list = [self._format_params(i) for i in params] |
|---|
| | 480 | return Database.Cursor.executemany(self, query, new_param_list) |
|---|