Opened 18 years ago

Closed 18 years ago

#2880 closed defect (worksforme)

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

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

Description

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.

Change History (5)

comment:1 by Michael Koloberdin <koloberdin@…>, 18 years ago

Resolution: worksforme
Status: newclosed

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

comment:2 by Malcolm Tredinnick, 18 years ago

Resolution: worksforme
Status: closedreopened

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.

in reply to:  2 comment:3 by mir@…, 18 years ago

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?

Thanks!

comment:4 by Michael Koloberdin <koloberdin@…>, 18 years ago

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 by Michael Radziej <mir@…>, 18 years ago

Resolution: worksforme
Status: reopenedclosed

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