django.db.utils.OperationalError:(1426,“精度太大 1000
Posted
技术标签:
【中文标题】django.db.utils.OperationalError:(1426,“精度太大 1000【英文标题】:django.db.utils.OperationalError: (1426, "Too big precision 1000 【发布时间】:2015-08-16 12:40:35 【问题描述】:当我尝试在 webfaction 上运行 python2.7 manage.py syncdb 时遇到以下问题。如果我没有提供正确的信息,我深表歉意,因为我对此很陌生。
Creating table carts_cartitem
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 533, in handle
return self.handle_noargs(**options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/commands/syncdb.py", line 27, in handle_noargs
call_command("migrate", **options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 115, in call_command
return klass.execute(*args, **defaults)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/commands/migrate.py", line 128, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/commands/migrate.py", line 239, in sync_apps
cursor.execute(statement)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/mysql/base.py", line 128, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1426, "Too big precision 1000 specified for column 'line_total'. Maximum is 65.")
【问题讨论】:
错误以及如何修复它就在堆栈跟踪的最后一行。您的模型上的line_total
字段的属性值超出了范围。
欢迎来到 ***!如果您包含 minimum, complete, verifiable example 并且您希望和实际输入,您更有可能获得有关您的问题的帮助。
我仍然不明白这一点,我唯一想到的是我可以让它在 sqlite3 的本地主机上完美运行,但是当我在 webfaction 上尝试使用 mysql 时出现错误。这是否能提供任何线索来说明我哪里出错了?
【参考方案1】:
请原谅我在这里缺乏知识,我似乎已经通过运行 python manage.py migrate --fake 解决了这个问题,现在我不再遇到以前的任何错误。
【讨论】:
以上是关于django.db.utils.OperationalError:(1426,“精度太大 1000的主要内容,如果未能解决你的问题,请参考以下文章