Newbie: Operational Error 1060 Duplicate column name

2,579 views
Skip to first unread message

Howard Wolf

unread,
Sep 22, 2010, 11:18:35 PM9/22/10
to Django users
I'm fairly new to django and I'm trying to restart an old database.

When I run the command run manage.py syncdb

I get the following error:

>run manage.py syncdb
Creating table slide_taxonomyphylum
ERROR: An unexpected error occured while tokenizing input
The following traceback may be be corrupted or invalid
The error message is: ('EOF in multi-line statement', (72,0))

ERROR: Internal Python error in the inspect module
Below is the traceback from this internal error

Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/IPython/ultraTB.py", line
667, in text
locals, formatvalue=var_rep))
File "/usr/lib/python2.6/inspect.py", line 875, in
formatargvalues
specs.append(strseq(args[i], convert, join))
File "/usr/lib/python2.6/inspect.py", line 830, in strseq
return convert(objects)
File "/usr/lib/python2.6/inspect.py", line 872, in convert
return formatarg(name) + formatvalue(locals[name])
KeyError: 'connection'

Not sure what this means. Help is greatly appreciate. I looked on
google for some help but didn't find much.

Karen Tracey

unread,
Sep 23, 2010, 7:26:48 AM9/23/10
to django...@googlegroups.com

First, where does the "Operational Error 1060 Duplicate column name" that you have in the title of this thread come in? I don't see it anywhere in your output.

Second, the traceback indicates you are running IPython, and the error message suggests some internal-to-python error. I'd try with regular Python and see what it does.

The title of the thread suggests an error involving a model with a duplicate column name (though how that could happen isn't clear -- you model definition for this table might help clarify). It's possible IPython is somehow tripping up on reporting the raised error and regular Python would give a less confusing error message, but since you don't show that database error anywhere in the output I'm not even sure that error from the thread title is related to the problem you have described in the email.

Karen
--
http://tracey.org/kmt/

Message has been deleted
Message has been deleted

Howard Wolf

unread,
Sep 23, 2010, 1:03:05 PM9/23/10
to Django users
I deleted the database and installed a new one with no tables at all.
Using regular Python I ran the script manage.py with subcommand
syncdb. It created the first 4 tables then hit an error. Here is the
traceback for the error.
Traceback (most recent call last):
File "manage.py", line 32, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 438, in execute_manager utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 191, in run_from_argv self.execute(*args,
**options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 218, in execute output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 347, in handle return self.handle_noargs(**options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
commands/syncdb.py", line 95, in handle_noargs
cursor.execute(statement)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
mysql/base.py", line 86, in execute return self.cursor.execute(query,
args)
File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in
executeself.errorhandler(self, exc, value)
File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line
35,in default errorhandler raise errorclass, errorvalue
OperationalError: (1060, "Duplicate column name
'taxonomy_kingdom_id'")
Does this mean that when it tries to create the table
slide_taxonomykingdom there is already a column with "id" and its
trying to make another one?

Here is the Python code that creates the two associated tables:

class TaxonomyKingdom(models.Model):
name = models.CharField(max_length=100, unique=True)
superior=0

def __unicode__(self):
return '%s' % (self.name)

class TaxonomyPhylum(models.Model):
name = models.CharField(max_length=100, unique=True)
superior=taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom,
null=True, blank=True)

def __unicode__(self):
return '%s' % (self.name)

Karen Tracey

unread,
Sep 23, 2010, 11:18:11 PM9/23/10
to django...@googlegroups.com
On Thu, Sep 23, 2010 at 1:03 PM, Howard Wolf <hwr...@gmail.com> wrote:
class TaxonomyPhylum(models.Model):
   name = models.CharField(max_length=100, unique=True)
   superior=taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom,
null=True, blank=True)

Do you want that ForeignKey field to be named superior or taxonomy_kingdom? Right now you've got 2 equal signs in there, and somehow that is causing Django to try to create two columns with the 2nd name (taxonomy_kingdom_id).

Karen
--
http://tracey.org/kmt/

Howard Wolf

unread,
Sep 23, 2010, 11:20:27 PM9/23/10
to django...@googlegroups.com
I want the foreign key to be called taxonomy_kingdom.

So would I do something like this?

taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom, null=True, blank=True)
superior=taxonomy_kingdom


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
************************************************
Howard Wolf, wolf18
Computer Science, University of Illinois, Urbana-Champaign

bruno desthuilliers

unread,
Sep 24, 2010, 6:44:11 AM9/24/10
to Django users


On 24 sep, 05:20, Howard Wolf <hwrd...@gmail.com> wrote:
> I want the foreign key to be called taxonomy_kingdom.
>
> So would I do something like this?
>
> taxonomy_kingdom = models.ForeignKey(TaxonomyKingdom, null=True, blank=True)
> superior=taxonomy_kingdom

This will yield the exact same result as your previous code snippet.
What are you trying to do with this 'superior=taxonomy_kingdom'
statement ? (and while we're at it, what are you trying to do with the
'superior=0' statement in TaxonomyKingdom ?)
Reply all
Reply to author
Forward
0 new messages