﻿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
2880	incompatibility with MySQL-python-1.2.2b1 or python-2.5	anonymous	Adrian Holovaty	"I'm new to Python and Django therefore not sure is it a bug of Django or Python module.
I've installed Python 2.5, MySQL-python-1.2.2b1 and django svn (rev. 3896).
When I run ""./manage.py syncdb"" - first time it works fine but subsequent runs throw an exception:
{{{
$ ./manage.py syncdb
Creating table auth_message
Traceback (most recent call last):
  File ""./manage.py"", line 11, in <module>
    execute_manager(settings)
  File ""/usr/local/lib/python2.5/site-packages/django/core/management.py"", line 1439, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File ""/usr/local/lib/python2.5/site-packages/django/core/management.py"", line 1347, in execute_from_command_line
    action_mapping[action](int(options.verbosity), options.interactive)
  File ""/usr/local/lib/python2.5/site-packages/django/core/management.py"", line 483, in syncdb
    cursor.execute(statement)
  File ""/usr/local/lib/python2.5/site-packages/django/db/backends/util.py"", line 12, in execute
    return self.cursor.execute(sql, params)
  File ""/usr/local/lib/python2.5/site-packages/django/db/backends/mysql/base.py"", line 42, in execute
    return self.cursor.execute(sql, params)
  File ""/usr/local/lib/python2.5/site-packages/MySQLdb/cursors.py"", line 166, in execute
    self.errorhandler(self, exc, value)
  File ""/usr/local/lib/python2.5/site-packages/MySQLdb/connections.py"", line 35, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, ""Table 'auth_message' already exists"")
}}}

To make long story short, applying the following pathch to django/db/backends/mysql/introspection.py fixes the problem but I guess that it will break it for older versions MySQL-python or python itself and also there should be similar problems in other places of django code
{{{
--- introspection.py    (revision 3896)
+++ introspection.py    (working copy)
@@ -8,7 +8,7 @@
 def get_table_list(cursor):
     ""Returns a list of table names in the current database.""
     cursor.execute(""SHOW TABLES"")
-    return [row[0] for row in cursor.fetchall()]
+    return [row[0].pop() for row in cursor.fetchall()]

 def get_table_description(cursor, table_name):
     ""Returns a description of the table, with the DB-API cursor.description interface.""
}}}
'''Please advise how to properly fix this issue.'''"	defect	closed	Database layer (models, ORM)	dev	major	worksforme		koloberdin@…	Unreviewed	0	0	0	0	0	0
