eclipse 4.4
python 2.7
django 1.10
mysql 5.71、我在finnews数据库下建了finnews表格,
2、django正常运行创建了finnews_finnews表格,
3、但是由于一些别的原因,admin中无法编辑和打开finnewss表格,于是我把finnews表格和finnews_finnews表格都删了,
4、再重新migrate,可是始终无法创建finnews_finnews表格,
日志如下D:\showwho\mysite>python manage.py makemigrations
Migrations for 'FinNews':
FinNews\migrations\0002_auto_20161111_0904.py:
- Alter field id on finnews
- Alter field shijian on finnews
- Alter field xinwen on finnewsD:\showwho\mysite>python manage.py migrate
Operations to perform:
Apply all migrations: FinNews, admin, auth, contenttypes, sessions
Running migrations:
Applying FinNews.0002_auto_20161111_0904...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Python27\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Python27\lib\site-packages\django\core\management\base.py", line 345, in execute
output = self.handle(*args, **options)
File "D:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 204, in handle
fake_initial=fake_initial,
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "D:\Python27\lib\site-packages\django\db\migrations\migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "D:\Python27\lib\site-packages\django\db\migrations\operations\fields.py", line 204, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "D:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 495, in alter_field
old_db_params, new_db_params, strict)
File "D:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 683, in _alter_field
self.execute(self._create_index_sql(model, [new_field], suffix="_uniq"))
File "D:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 112, in execute
cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 110, in execute
return self.cursor.execute(query, args)
File "D:\Python27\lib\site-packages\pymysql\cursors.py", line 166, in execute
result = self._query(query)
File "D:\Python27\lib\site-packages\pymysql\cursors.py", line 322, in _query
conn.query(q)
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 835, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 1019, in _read_query_result
result.read()
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 1302, in read
first_packet = self.connection._read_packet()
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 981, in _read_packet
packet.check_error()
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "D:\Python27\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.ProgrammingError: (1146, u"Table 'finnews.finnews_finnews' doesn't exist")
python 2.7
django 1.10
mysql 5.71、我在finnews数据库下建了finnews表格,
2、django正常运行创建了finnews_finnews表格,
3、但是由于一些别的原因,admin中无法编辑和打开finnewss表格,于是我把finnews表格和finnews_finnews表格都删了,
4、再重新migrate,可是始终无法创建finnews_finnews表格,
日志如下D:\showwho\mysite>python manage.py makemigrations
Migrations for 'FinNews':
FinNews\migrations\0002_auto_20161111_0904.py:
- Alter field id on finnews
- Alter field shijian on finnews
- Alter field xinwen on finnewsD:\showwho\mysite>python manage.py migrate
Operations to perform:
Apply all migrations: FinNews, admin, auth, contenttypes, sessions
Running migrations:
Applying FinNews.0002_auto_20161111_0904...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Python27\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Python27\lib\site-packages\django\core\management\base.py", line 345, in execute
output = self.handle(*args, **options)
File "D:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 204, in handle
fake_initial=fake_initial,
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "D:\Python27\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "D:\Python27\lib\site-packages\django\db\migrations\migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "D:\Python27\lib\site-packages\django\db\migrations\operations\fields.py", line 204, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "D:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 495, in alter_field
old_db_params, new_db_params, strict)
File "D:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 683, in _alter_field
self.execute(self._create_index_sql(model, [new_field], suffix="_uniq"))
File "D:\Python27\lib\site-packages\django\db\backends\base\schema.py", line 112, in execute
cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "D:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 110, in execute
return self.cursor.execute(query, args)
File "D:\Python27\lib\site-packages\pymysql\cursors.py", line 166, in execute
result = self._query(query)
File "D:\Python27\lib\site-packages\pymysql\cursors.py", line 322, in _query
conn.query(q)
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 835, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 1019, in _read_query_result
result.read()
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 1302, in read
first_packet = self.connection._read_packet()
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 981, in _read_packet
packet.check_error()
File "D:\Python27\lib\site-packages\pymysql\connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "D:\Python27\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.ProgrammingError: (1146, u"Table 'finnews.finnews_finnews' doesn't exist")
解决方案 »
- 带参数的SQL语句
- 求一条SQL语句,删除字段中的所有符号
- 如何以UTF8的形式插入一条记录到MySQL数据库
- POSTGRESQL 什么时候可以解决这些关键问题?
- 怎样分几次向MySQL数据库中insert into数据?
- 【求助】关于mysql认证的问题
- Sql数据库中仅有一个information_schema,且不能创建新的数据库 求解?!
- MyISAM高并发insert delete 该如何处理
- sql子查询问题
- MySQL在MyBatis下的输出问题
- 【MYSQL】ERROR 1045 (28000): Access denied for user 'root'@'localhost'
- mysql update成功,select没有值
BEGIN;
--
-- Create model FinNews
--
CREATE TABLE `FinNews_finnews` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `shijian` date NOT NULL, `xinwen` longtext NOT NULL);
COMMIT;
1、彻底删除相关database和dajango app;
2、重新建database,命名brandnew,重现建app,命名brandnew;
3、以上过程在往下的过程中,还会碰到各种error,所以可以无数遍重复;
4、由于有无数遍重复,记得删除brandnew下的migration文件夹中的带数字文档,并且在使用python manage.py migrate的时候加上--fake-initial。最终搞定,经验就是不要怕删除已有成就,不要怕一切从头再来。
电脑经常会因为人为或非人为的原因产生莫名其妙的错误。
只要排除一切认为错误因素,用一遍遍的restart排除非人为因素,成功就在眼前。