Skip to content

Commit

Permalink
Add purge_topics.py to scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
basicthinker committed Jun 6, 2023
1 parent 34f43ad commit 48fab3d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/purge_topics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
from tinydb import TinyDB


def remove_topic_table(file_path: str):
try:
db = TinyDB(file_path)
if 'topics' in db.tables():
db.drop_table('topics')
print("The 'topics' table has been removed.")
else:
print("The file does not contain a 'topics' table.")
except Exception as exc:
print(f"Error: {exc}. The file is not a valid TinyDB file or could not be processed.")


if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python remove_topic_table.py <file_path>")
sys.exit(1)

remove_topic_table(sys.argv[1])

0 comments on commit 48fab3d

Please sign in to comment.