From 0162a3b54fe5424b0daf60abdb870c4f00d977df Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 10 Apr 2006 00:32:42 +0000 Subject: [PATCH] Fixed #1590 -- Changed MySQL get_last_insert_id() implementation to use cursor.lastrowid instead of a separate SELECT statement. Thanks, Andy Dustman git-svn-id: http://code.djangoproject.com/svn/django/trunk@2645 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/db/backends/mysql.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/django/core/db/backends/mysql.py b/django/core/db/backends/mysql.py index 1b67fc8615..d0e27e6f44 100644 --- a/django/core/db/backends/mysql.py +++ b/django/core/db/backends/mysql.py @@ -110,8 +110,7 @@ class DatabaseWrapper(local): return "`%s`" % name def get_last_insert_id(cursor, table_name, pk_name): - cursor.execute("SELECT LAST_INSERT_ID()") - return cursor.fetchone()[0] + return cursor.lastrowid def get_date_extract_sql(lookup_type, table_name): # lookup_type is 'year', 'month', 'day'