Opened 19 years ago
Closed 19 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 , 19 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
follow-up: 3 comment:2 by , 19 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → 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 by , 19 years ago
| Cc: | 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 , 19 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 , 19 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | reopened → closed |
Looks like a bug within python-MySQLdb-1.2.1b1. Please reopen if you can reproduce it with a newer version.
Apparently MySQL-python-1.2.2b1 does not work properly with MySQL 4.0.
Works fine with MySQL-5.0.24a