﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
4765	sqlite3 executemany wrapper fails with empty parameter list	jdetaeye@…	nobody	"
The following statement fails with the sqlite wrapper:
{{{
  cursor = connection.cursor()
  cursor.executemany(""insert into test (name) values(%s)"",[])
}}}

It raises an IndexError exception when the code tries to pick up the first element in the parameter list. [[BR]]
The code is in the following statements in the file django\db\backends\sqlite3\base.py :
{{{
    def executemany(self, query, param_list):
        query = self.convert_query(query, len(param_list[0]))
        return Database.Cursor.executemany(self, query, param_list)
}}}

An obvious fix is as follows:
{{{
    def executemany(self, query, param_list):
        try:
          query = self.convert_query(query, len(param_list[0]))
          return Database.Cursor.executemany(self, query, param_list)
        except IndexError:
          # No parameter list provided
          return None
}}}
"		closed	Database layer (models, ORM)	dev		fixed	sqlite3		Unreviewed	0	0	0	0	0	0
