Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I drop a table from SQLite3 in DJango?

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.

like image 708
Alex Avatar asked Feb 18 '10 04:02

Alex


People also ask

How do you drop a table in SQLite python?

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.

How would you drop a table in SQLite database?

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.

How do I drop a database in sqlite3 Python?

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.


1 Answers

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 
like image 198
Adrián Deccico Avatar answered Sep 18 '22 18:09

Adrián Deccico