Code

Opened 8 years ago

Closed 8 years ago

#1558 closed defect (wontfix)

[magic-removal] syncdb no longer working [patch]

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

Description

$ django-admin.py syncdb
Creating table auth_message
Traceback (most recent call last):

File "/usr/local/bin/django-admin.py", line 5, in ?

management.execute_from_command_line()

File "/magik/django/core/management.py", line 1107, in execute_from_command_line

action_mapping[action]()

File "/magik/django/core/management.py", line 456, in syncdb

cursor.execute(statement)

File "/magik/django/db/backends/util.py", line 12, in execute

return self.cursor.execute(sql, params)

File "/magik/django/db/backends/mysql/base.py", line 31, in execute

return self.cursor.execute(sql, params)

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/MySQLdb/cursors.py", line 137, in execute

self.errorhandler(self, exc, value)

File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/MySQLdb/connections.py", line 33, in defaulterrorhandler

raise errorclass, errorvalue

_mysql_exceptions.OperationalError: (1050, "Table 'auth_message' already exists")
ianh@Circe:/magik/zilbo$

Attachments (0)

Change History (4)

comment:1 Changed 8 years ago by adrian

  • Summary changed from MR:syncdb no longer working to [magic-removal] syncdb no longer working

Note: I cannot reproduce this with Postgres.

comment:2 Changed 8 years ago by adrian

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

I can't reproduce this with MySQL, either -- on version 4.1.12, at least. Please reopen this ticket if you have more information on why this is happening.

comment:3 Changed 8 years ago by ian@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Summary changed from [magic-removal] syncdb no longer working to [magic-removal] syncdb no longer working [patch]

it's a case issue.
mysql has my table name as auth_Messages, where the model is thinking it should be auth_messages
this can happen when you are importing a legacy DB.

Index: introspection.py
===================================================================
--- introspection.py    (revision 2602)
+++ introspection.py    (working copy)
@@ -5,7 +5,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].lower() 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."

comment:4 Changed 8 years ago by jacob

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

Then you need to set db_table in your model; having get_table_list() not return the correct table names is going to be disasterous to introspection.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.