Updated SQL Script?

2 views
Skip to first unread message

Eric Peters

unread,
Aug 12, 2009, 12:39:25 PM8/12/09
to cnp...@googlegroups.com
I managed to trigger another error about a missing table - can someone create an updated SQL install script?

Also, is it possible that the SQL scripts wouldn't explicitly have the actual database name in them (like just a create table)/etc?

This happend when I tried posting an anonymous question:

ProgrammingError at /questions/ask/
(1146, "Table 'answers_development.forum_anonymousquestion' doesn't exist")

Evgeny

unread,
Aug 12, 2009, 12:41:38 PM8/12/09
to CNProg open discussion
Eric,
try to run manage.py syncdb
it should install the missing tables
Evgeny.

Eric Peters

unread,
Aug 12, 2009, 12:44:07 PM8/12/09
to cnp...@googlegroups.com
Interesting...

eric@eric-peterss-macbook-pro:~/work/answers$ python manage.py syncdb
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-macosx-10.5-universal.egg/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
Creating table forum_emailfeed
Creating table tag
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 361, in execute_manager
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 306, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 192, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 219, in execute
    output = self.handle(*args, **options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 348, in handle
    return self.handle_noargs(**options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 80, in handle_noargs
    cursor.execute(statement)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in execute
    return self.cursor.execute(sql, params)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 83, in execute
    return self.cursor.execute(query, args)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-macosx-10.5-universal.egg/MySQLdb/cursors.py", line 166, in execute
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-macosx-10.5-universal.egg/MySQLdb/connections.py", line 35, in defaulterrorhandler
_mysql_exceptions.OperationalError: (1050, "Table 'tag' already exists")
eric@eric-peterss-macbook-pro:~/work/answers$ 

Eric Peters

unread,
Aug 12, 2009, 12:49:25 PM8/12/09
to Eric Peters, cnp...@googlegroups.com
OK so somehow the table name was Tag instead of tag

eric@eric-peterss-macbook-pro:~/work/answers/sql_scripts$ grep Tag *
update_2009_04_10_001.sql:ALTER TABLE Tag ADD COLUMN deleted_at datetime default null;
update_2009_04_10_001.sql:ALTER TABLE Tag ADD COLUMN deleted_by_id INTEGER NULL;
update_2009_04_10_001.sql:ALTER TABLE Tag ADD COLUMN deleted TINYINT NOT NULL;

I renamed the table to 'tag' lowercase and the script ran fine:

eric@eric-peterss-macbook-pro:~/work/answers$ python manage.py syncdb
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-macosx-10.5-universal.egg/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
Creating table forum_anonymousanswer
Creating table forum_anonymousquestion
Creating table forum_anonymousemail
Installing index for forum.AnonymousAnswer model
Installing index for forum.AnonymousQuestion model

Thanks!

-Eric

Interesting...

Evgeny

unread,
Aug 12, 2009, 12:56:08 PM8/12/09
to CNProg open discussion
strange. I have not seen this problem.
below is the sql script that might help - i hope


--
-- Table structure for table `forum_anonymousanswer`
--

DROP TABLE IF EXISTS `forum_anonymousanswer`;
CREATE TABLE `forum_anonymousanswer` (
`id` int(11) NOT NULL auto_increment,
`question_id` int(11) NOT NULL,
`session_key` varchar(40) NOT NULL,
`wiki` tinyint(1) NOT NULL,
`added_at` datetime NOT NULL,
`ip_addr` char(15) NOT NULL,
`author_id` int(11) default NULL,
`text` longtext NOT NULL,
`summary` varchar(180) NOT NULL,
PRIMARY KEY (`id`),
KEY `forum_anonymousanswer_question_id` (`question_id`),
KEY `forum_anonymousanswer_author_id` (`author_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `forum_anonymousemail`
--

DROP TABLE IF EXISTS `forum_anonymousemail`;
CREATE TABLE `forum_anonymousemail` (
`id` int(11) NOT NULL auto_increment,
`key` varchar(32) NOT NULL,
`email` varchar(75) NOT NULL,
`isvalid` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Table structure for table `forum_anonymousquestion`
--

DROP TABLE IF EXISTS `forum_anonymousquestion`;
CREATE TABLE `forum_anonymousquestion` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(300) NOT NULL,
`session_key` varchar(40) NOT NULL,
`text` longtext NOT NULL,
`summary` varchar(180) NOT NULL,
`tagnames` varchar(125) NOT NULL,
`wiki` tinyint(1) NOT NULL,
`added_at` datetime NOT NULL,
`ip_addr` char(15) NOT NULL,
`author_id` int(11) default NULL,
PRIMARY KEY (`id`),
KEY `forum_anonymousquestion_author_id` (`author_id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Table structure for table `forum_emailfeed`
--

DROP TABLE IF EXISTS `forum_emailfeed`;
CREATE TABLE `forum_emailfeed` (
`id` int(11) NOT NULL auto_increment,
`key` varchar(32) NOT NULL,
`feed_content_type_id` int(11) NOT NULL,
`feed_id` int(10) unsigned NOT NULL,
`subscriber_content_type_id` int(11) NOT NULL,
`subscriber_id` int(10) unsigned NOT NULL,
`added_at` datetime NOT NULL,
`reported_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `forum_emailfeed_feed_content_type_id` (`feed_content_type_id`),
KEY `forum_emailfeed_subscriber_content_type_id`
(`subscriber_content_type_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

ALTER TABLE auth_user ADD COLUMN email_isvalid TINYINT(1) NOT NULL;
UPDATE auth_user SET email_isvalid=1;
ALTER TABLE auth_user ADD COLUMN email_key varchar(32);

Evgeny

unread,
Aug 12, 2009, 12:57:31 PM8/12/09
to CNProg open discussion
if you use email validation you'll need to run this:

ALTER TABLE auth_user ADD COLUMN email_isvalid TINYINT(1) NOT NULL;
UPDATE auth_user SET email_isvalid=1;
ALTER TABLE auth_user ADD COLUMN email_key varchar(32);

On Aug 12, 9:49 am, Eric Peters <ericpet...@gmail.com> wrote:
> OK so somehow the table name was Tag instead of tag
> eric@eric-peterss-macbook-pro:~/work/answers/sql_scripts$ grep Tag *
> update_2009_04_10_001.sql:ALTER TABLE Tag ADD COLUMN deleted_at datetime
> default null;
> update_2009_04_10_001.sql:ALTER TABLE Tag ADD COLUMN deleted_by_id INTEGER
> NULL;
> update_2009_04_10_001.sql:ALTER TABLE Tag ADD COLUMN deleted TINYINT NOT
> NULL;
>
> I renamed the table to 'tag' lowercase and the script ran fine:
>
> eric@eric-peterss-macbook-pro:~/work/answers$ python manage.py syncdb
> /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-macosx-10.5-universal.egg/MySQLdb/__init__.py:34:
> DeprecationWarning: the sets module is deprecated
> Creating table forum_anonymousanswer
> Creating table forum_anonymousquestion
> Creating table forum_anonymousemail
> Installing index for forum.AnonymousAnswer model
> Installing index for forum.AnonymousQuestion model
>
> Thanks!
>
> -Eric
>
Reply all
Reply to author
Forward
0 new messages