Django flush vs sqlclear & syncdb

爱⌒轻易说出口 提交于 2019-12-03 08:40:25

问题


Can anyone tell if there is a difference between

>manage.py flush  # or reset

and

>manage.py sqlclear appname | python manage.py dbshell
>manage.py syncdb 

回答1:


flush will truncate (delete data)

sqlclear will drop (delete table, thus data too)

=> if you have structural modifications in your db, you have to do sqlclear (but better use south)

Update:

South has been deprecated.

From Django 1.7 upwards, migrations are built into the core of Django. If you are running a previous version, you can use South.




回答2:


Official docs for

flush and sqlclear

Flush carries out the SQL Drops on the entire db, sqlflush only prints out the SQL that flush would actual run (again on the entire db). sqlclear prints out SQL Drops for a particular app or apps. Both flush and sqlflush/dbshell/syncdb will install fixtures.



来源:https://stackoverflow.com/questions/7598024/django-flush-vs-sqlclear-syncdb

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