Opened 9 years ago

Closed 9 years ago

#2880 closed defect (worksforme)

incompatibility with MySQL-python-1.2.2b1 or python-2.5

Reported by: anonymous Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: major Keywords:
Cc: koloberdin@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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 "./ syncdb" - first time it works fine but subsequent runs throw an exception:

$ ./ syncdb
Creating table auth_message
Traceback (most recent call last):
  File "./", line 11, in <module>
  File "/usr/local/lib/python2.5/site-packages/django/core/", line 1439, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "/usr/local/lib/python2.5/site-packages/django/core/", 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/", line 483, in syncdb
  File "/usr/local/lib/python2.5/site-packages/django/db/backends/", line 12, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.5/site-packages/django/db/backends/mysql/", line 42, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.5/site-packages/MySQLdb/", line 166, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.5/site-packages/MySQLdb/", 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/ 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

---    (revision 3896)
+++    (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.

Change History (5)

comment:1 Changed 9 years ago by Michael Koloberdin <koloberdin@…>

  • Resolution set to worksforme
  • Status changed from new to closed

Apparently MySQL-python-1.2.2b1 does not work properly with MySQL 4.0.
Works fine with MySQL-5.0.24a

comment:2 follow-up: Changed 9 years ago by mtredinnick

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Since Django does not just support MySQL > 5.0, we need to preferably work around this or at least display a warning. Reopening until we can work out a fix that is sufficiently portable.

comment:3 in reply to: ↑ 2 Changed 9 years ago by mir@…

  • Cc koloberdin@… added

Hi Michael, can you please give us a bit of additional information:

  • what mysql database version did you use?
  • what's the output of 'show create table foo' (for any table that exists)?
  • does python-mysql-1.2.2b2 fix it?


comment:4 Changed 9 years ago by Michael Koloberdin <koloberdin@…>

It was mysql-4.1.20 (not sure though as it was several months ago).
Sorry I can not reproduce 'show create table' with mysql-4 or check new python module with mysql-4 as I do not have any host with mysql-4 at the moment.

comment:5 Changed 9 years ago by Michael Radziej <mir@…>

  • Resolution set to worksforme
  • Status changed from reopened to closed

Looks like a bug within python-MySQLdb-1.2.1b1. Please reopen if you can reproduce it with a newer version.

Note: See TracTickets for help on using tickets.
Back to Top