chore: Add function to clear the database

This commit is contained in:
unclecode
2024-05-09 19:42:43 +08:00
parent f7c031c097
commit 181250cb93
4 changed files with 20 additions and 5 deletions

View File

@@ -50,4 +50,12 @@ def get_total_count(db_path: str) -> int:
conn.close()
return result[0]
except Exception as e:
return 0
return 0
# Crete function to cler the database
def clear_db(db_path: str):
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute('DELETE FROM crawled_data')
conn.commit()
conn.close()