问题
After some testing with Django on PythonAnywhere, I want to get rid of my testing data before I import my actual data to the postgres database. I thought the best way would be to start from scratch and "reset" somehow the database.
Unfortunately there is no button for that on pythonanywhere.com and the documentation does not say anything.
So the question is: how can I "reset" or empty the postgres database on PythonAnywhere?
回答1:
With the help of the PythonAnywhere support I found a way which worked for me: I deleted and re-created my database (called postgres) as follows:
Open a bash console (not a virtualenv console!) and execute the following commands:
dropdb -h xxx.postgres.eu.pythonanywhere-services.com -p 10077 -U super postgres
createdb -h xxx.postgres.eu.pythonanywhere-services.com -p 10077 -U super postgres
(replace above xxx
with your data)
来源:https://stackoverflow.com/questions/64759855/how-to-reset-a-postgres-database-on-pythonanywhere