Django Is telling me table already exists on syncdb - can't figure out why

烈酒焚心 提交于 2019-12-11 12:37:08

问题


Posted the model at http://pastebin.com/f609771cc

getting error: (yes it's windows) File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.OperationalError: (1050, "Table 'memorial_music' already exists")

scanned the whole project directory and memorial_music is only referenced twice

once as a table name and once as table name 'memorial_music_category'

this one has me scratching my head, any ideas?


回答1:


django-mptt was the culprit

renamed table for memorial_music to memorial_music_library and everything went smooth

thank you django for manage.py sqlall appname




回答2:


Being a Django newbie I was having syncdb problems all the time. Every time I would run it I would get Error ** table already exists. After searching for answers with no avail and reading over and over again that syncdb : "Creates the database tables for all apps in INSTALLED_APPS whose tables have not already been created.". I finally realized that when I did the initial python manage.py startapp UserData .... the capitalization of UserData was messing Django up (I'm using MYSQL). If would have called it userData I wouldn't have had any problems. I hope this helps someone with the same problem I had.

Edit **

Maybe it wasn't a problem with the capitalization, I think naming a table called userData in Django just doesn't work overall.




回答3:


I have the same problem today. Make sure all of your project folders names are lowercase. I think it would all work out.




回答4:


The complaint is that the table already exists in the database. Django cannot update an existing table. You either need to drop the table from the MySQL database, and syncdb again, or manually adjust the table schema to the model.



来源:https://stackoverflow.com/questions/1283792/django-is-telling-me-table-already-exists-on-syncdb-cant-figure-out-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!