问题描述
我正在运行syncdb来创建一个sqlite数据库。直到最近才开始工作,我看不到任何改变的东西会导致失败。我主要是改变了一些字段名称。我在models.py中有以下内容:
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b $ EmailField()
wp_userID = models.PositiveSmallIntegerField(unique = True)
当我运行syncdb删除旧的db文件后,我得到150行追溯,最后一部分是:
文件C:\\ \\ Python33\lib\site-packages\django\db\backends\util.py,第53行,执行
return self.cursor.execute(sql,params)
文件C:\Python33\lib\site- packages\django\db\backends\sqlite3\base.py,第450行,执行
return Database.Cursor.execute( self,query,params)
django.db.utils.OperationalError:没有这样的表:gameconapp_gc_user
有什么可能导致这种情况的想法?
谢谢!
更新:经过很多挖掘,我的合作伙伴确定问题是应用程序的 init.py 被调用。因为一个例程,它试图访问GC_User表,它得到没有这样的表错误。
现在我已经评论了,所以我可以运行syncdb,一次我们正在生产中,我们不会重置数据库,但是对于我来说,在数据库设置之前应用程序正在被初始化是违反直觉的。
我有一个本地SQLite 3数据库的这个问题。首先我删除了这个文件。
为了解决这个问题,我使用了 syncdb --no-initial-data
然后继续使用迁移
,其中提到的每个应用程序被声明为不被同步:
code> ./ manage.py syncdb --no-initial-data
./manage.py migrate app1
./manage.py migrate app2
./manage.py migrate app3
没有保证的订单,所以这必须手动完成,只需检查什么顺序为您工作。在我的情况下, simple_email_confirmation
应用程序必须首先在其他任何事情之前完成。经过几次尝试, ./ manage.py migrate
自己应该可以工作。
I'm running syncdb to create an sqlite db. It was working until recently, and I don't see anything I've changed that would cause it to fail. Mostly I just changed some field names.
I have the following in models.py:
class GC_User(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
email = models.EmailField()
wp_userID = models.PositiveSmallIntegerField(unique=True)
When I run syncdb after deleting the old db file, I get 150 lines of traceback, the last part of which is:
File "C:\Python33\lib\site-packages\django\db\backends\util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "C:\Python33\lib\site-packages\django\db\backends\sqlite3\base.py", line 450, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: gameconapp_gc_user
Any thoughts about what might be causing this? I can put in more of the traceback if that would be helpful.
Thanks!
Update: After much digging, my partner determined that the problem was that the application's init.py was getting called. Since a routine there tried to access the GC_User table, it got the no such table error.
For now I've commented it out so I could run syncdb, and once we're in production we won't be resetting the db, but it's counterintuitive to me that the application is being initialized before the database is set up.
I had this issue with a local SQLite 3 database. First I removed the file to be sure.
To solve this issue I used syncdb --no-initial-data
then proceeded to use migrate
with each app mentioned that was stated to not be synced:
./manage.py syncdb --no-initial-data
./manage.py migrate app1
./manage.py migrate app2
./manage.py migrate app3
There is no guaranteed order so this has to be done manually and just check what order works for you. In my case the simple_email_confirmation
app had to be done first before anything else. After a few tries, ./manage.py migrate
on its own should work.
这篇关于OperationalError:初始syncdb没有这样的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!