0

Is there any way to delete all the tables from sqlite database or clean the specific database storage in python?

We have a database - myproject.db in sqlite, and have 13 tables in it. We have to clean the storage as after the tables data is processed , we want new data to be stored in it.

7
  • 2
    stackoverflow.com/questions/27606518/… Commented May 2, 2023 at 12:39
  • Please suggest in python @SembeiNorimaki Commented May 2, 2023 at 13:57
  • 1
    Can't you run SQL queries in python? The answer will vary depending which libraries you use. Are you using SQLAlchemy or some other library in python? Commented May 2, 2023 at 14:07
  • we can't delete db in sqlite, how can we delete file in sqlite , using sqlite3 library in python? Commented May 2, 2023 at 14:38
  • "We have to clean the storage as after the tables data is processed , we want new data to be stored in it" it looks like you don't want to delete the tables but empty them instead. Those are very different things. Do you want this tables to be deleted or emptied? My link and the answer you got are about how to delete (drop) tables, which might not be what you want at all. Commented May 2, 2023 at 14:50

1 Answer 1

-1

Try with this DROP TABLE IF EXISTS table_name

Sign up to request clarification or add additional context in comments.

5 Comments

That doens't answer the question: OP asked a way to delete all the tables without specifying them one by one
we want to drop database or all the tables from it insqlite?
@pp45 Do your really want to drop those tables and create them again? Or you just want to delete the data inside this tables?
To add to the comments already made, this answer also is not how to do it in python, which is part of the question above. Suggest you read the question more thoroughly to make sure you are answering it exactly. Also FWIW seems like this question could have been answered by linking existing answers to how to execute sql commands from python and how to drop all tables in sql.
To add to the comments already made, this answer also is not how to do it in python, which is part of the question above. Suggest you read the question more thoroughly to make sure you are answering it exactly. Also FWIW seems like this question could have been answered by linking existing answers to how to execute sql commands from python and how to drop all tables in sql.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.