Opened 20 years ago
Closed 20 years ago
#1558 closed defect (wontfix)
[magic-removal] syncdb no longer working [patch]
| Reported by: | Owned by: | Adrian Holovaty | |
|---|---|---|---|
| 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: | no | UI/UX: | no |
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$
Change History (4)
comment:1 by , 20 years ago
| Summary: | MR:syncdb no longer working → [magic-removal] syncdb no longer working |
|---|
comment:2 by , 20 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → 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 by , 20 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → reopened |
| Summary: | [magic-removal] syncdb no longer working → [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 by , 20 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | reopened → 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.
Note: I cannot reproduce this with Postgres.