#4765: sqlite3 executemany wrapper fails with empty parameter list
-------------------------------------+--------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Status: new | Component: Database wrapper
Version: SVN | Keywords: sqlite3
Stage: Unreviewed | Has_patch: 0
-------------------------------------+--------------------------------------
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
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/4765>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---