I made a model, and ran python manage.py syncdb. I think that created a table in the db. Then I realized that I had made a column incorrectly, so I changed it, and ran the same command, thinking that it would drop the old table, and add a new one.
Then I went to python manage.py shell, and tried to run .objects.all(), and it failed, saying that column doesn't exist.
I want to clear out the old table, and then run syncdb again, but I can't figure out how to do that.
To drop a table from a SQLite3 database using python invoke the execute() method on the cursor object and pass the drop statement as a parameter to it.
To drop a table in SQLite, use the DROP TABLE statement. Running this statement removes the table from the database. It is completely removed from the database schema and the disk file. Therefore the table can not be recovered.
There is no command in sqlite to drop a database, as the database is saved in a file. To drop it you would just delete the file.
to clear out an application is as simple as writing:
./manage.py sqlclear app_name | ./manage.py dbshell
then in order to rebuild your tables just type:
./manage.py syncdb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With