PensionBot / reset_database.py
ChAbhishek28's picture
Add 899999999999999999999999
224c593
raw
history blame
1.24 kB
#!/usr/bin/env python3
"""
Reset the LanceDB database and reload with new diverse content
"""
import asyncio
import logging
import shutil
import os
from pathlib import Path
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("reset_db")
async def reset_database():
"""Reset the database and reload with diverse content"""
try:
# Path to the database directory
db_path = Path("lancedb_data")
if db_path.exists():
logger.info("πŸ—‘οΈ Removing existing database...")
shutil.rmtree(db_path)
logger.info("βœ… Existing database removed")
# Recreate the database directory
db_path.mkdir(exist_ok=True)
logger.info("πŸ“ Created new database directory")
# Now run the setup documents script
logger.info("πŸ“š Loading new diverse documents...")
from setup_documents import setup_sample_documents
await setup_sample_documents()
logger.info("πŸŽ‰ Database reset complete with diverse content!")
except Exception as e:
logger.error(f"❌ Error resetting database: {e}")
if __name__ == "__main__":
asyncio.run(reset_database())