Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Django删除postgresql数据库中的所有表,而不删除数据库_Python_Django_Postgresql_Amazon Web Services_Cloud - Fatal编程技术网

Python 使用Django删除postgresql数据库中的所有表,而不删除数据库

Python 使用Django删除postgresql数据库中的所有表,而不删除数据库,python,django,postgresql,amazon-web-services,cloud,Python,Django,Postgresql,Amazon Web Services,Cloud,我正在运行AWS Elastic Beans,它会自动为我设置一个工作的postgresql数据库实例和连接。因此,我不想只删除数据库实例并自己配置它。我宁愿从python/django中删除数据库中的所有表。我也不想删除所有表的内容(python manage.py flush的功能) 我希望数据库返回到可以运行python manage.py migrate的状态,它将根据当前模型定义创建所有空表 谢谢我不想删除表中的所有数据,我想删除表本身,这样我就可以在以后运行一个新的python ma

我正在运行AWS Elastic Beans,它会自动为我设置一个工作的postgresql数据库实例和连接。因此,我不想只删除数据库实例并自己配置它。我宁愿从python/django中删除数据库中的所有表。我也不想删除所有表的内容(python manage.py flush的功能)

我希望数据库返回到可以运行
python manage.py migrate
的状态,它将根据当前模型定义创建所有空表


谢谢

我不想删除表中的所有数据,我想删除表本身,这样我就可以在以后运行一个新的python manage.py migrate,以使用我的新(可能已更改)模型获得干净的表。python manage.py migrate appname zero-命令将删除您的table@IainShelvington是的,的确如此,谢谢
# Prints the SQL statements that would be executed for the flush command. Will delete all the data from tables in database

django-admin sqlflush

# You can pass the name of your database specifically. Defaults to default.

--database DATABASE

# If you want to delete all the tables of your app, then you can run the command

python manage.py migrate appname zero