Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

Remove deprecated news init_tables.py script

LearningCircuitae25758dbd2a
diff --git a/src/local_deep_research/news/init_tables.py b/src/local_deep_research/news/init_tables.py
deleted file mode 100755
index fa84c85c35..0000000000
--- a/src/local_deep_research/news/init_tables.py
+++ /dev/null
@@ -1,179 +0,0 @@
-#!/usr/bin/env python3
-"""
-DEPRECATED: This script is obsolete.
-News tables are now created in per-user encrypted databases.
-Do not use the shared database.
-"""
-
-import sys
-from pathlib import Path
-from sqlalchemy import create_engine, inspect
-from loguru import logger
-
-# Add parent directory to path for imports
-sys.path.insert(0, str(Path(__file__).parent.parent.parent))
-
-from local_deep_research.database.models import (
- Base,
- NewsSubscription as BaseSubscription,
- SubscriptionFolder,
- UserPreference,
- UserRating as Rating,
- NewsCard,
-)
-from local_deep_research.news.core.base_card import CardVersion
-
-
-def init_news_tables(db_path=None):
- """
- Initialize all news tables in the database.
-
- Args:
- db_path: Path to the database file. If None, uses the default shared database location.
-
- Returns:
- bool: True if successful, False otherwise
- """
- if db_path is None:
- # Use the default shared database location in data directory
- data_dir = Path(__file__).parent.parent.parent.parent / "data"
- data_dir.mkdir(exist_ok=True)
- db_path = data_dir / "shared.db"
-
- db_path = Path(db_path).absolute()
-
- if not db_path.exists():
- logger.error(f"Database not found at {db_path}")
- logger.info(
- "Please ensure the main application has been run at least once to create the database."
- )
- return False
-
- try:
- # Create engine
- engine = create_engine(f"sqlite:///{db_path}", echo=False)
- inspector = inspect(engine)
-
- logger.info(f"Initializing news tables in {db_path}")
-
- # List of tables to create
- tables_to_create = [
- ("news_subscriptions", BaseSubscription.__table__),
- ("news_subscription_folders", SubscriptionFolder.__table__),
- ("news_user_preferences", UserPreference.__table__),
- ("news_ratings", Rating.__table__),
- ("news_cards", NewsCard.__table__),
- ("news_card_versions", CardVersion.__table__),
- ]
-
- created_count = 0
- for table_name, table_obj in tables_to_create:
- if not inspector.has_table(table_name):
- logger.info(f"Creating table: {table_name}")
- Base.metadata.create_all(engine, tables=[table_obj])
- created_count += 1
- else:
- logger.debug(f"Table already exists: {table_name}")
-
- if created_count > 0:
- logger.success(f"Successfully created {created_count} news tables")
- else:
- logger.info("All news tables already exist")
-
- # Verify all tables exist
- existing_tables = inspector.get_table_names()
- news_tables = [name for name, _ in tables_to_create]
- missing_tables = [t for t in news_tables if t not in existing_tables]
-
- if missing_tables:
- logger.error(f"Failed to create tables: {missing_tables}")
- return False
-
- return True
-
- except Exception as e:
- logger.exception(f"Failed to initialize news tables: {e}")
- import traceback
-
- traceback.print_exc()
- return False
-
-
-def verify_news_tables(db_path=None):
- """
- Verify that all news tables exist and show their structure.
-
- Args:
- db_path: Path to the database file. If None, uses the default shared database location.
- """
- if db_path is None:
- data_dir = Path(__file__).parent.parent.parent.parent / "data"
- db_path = data_dir / "shared.db"
-
- db_path = Path(db_path).absolute()
-
- if not db_path.exists():
- logger.error(f"Database not found at {db_path}")
- return
-
- try:
- engine = create_engine(f"sqlite:///{db_path}", echo=False)
- inspector = inspect(engine)
-
- logger.info(f"Verifying news tables in {db_path}")
-
- news_tables = [
- "news_subscriptions",
- "news_subscription_folders",
- "news_user_preferences",
- "news_ratings",
- "news_cards",
- "news_card_versions",
- ]
-
- for table_name in news_tables:
- if inspector.has_table(table_name):
- logger.success(f"✓ Table exists: {table_name}")
- # Show columns
- columns = inspector.get_columns(table_name)
- for col in columns:
- logger.debug(f" - {col['name']}: {col['type']}")
- else:
- logger.error(f"✗ Table missing: {table_name}")
-
- except Exception as e:
- logger.exception(f"Failed to verify news tables: {e}")
- import traceback
-
- traceback.print_exc()
-
-
-if __name__ == "__main__":
- import argparse
-
- parser = argparse.ArgumentParser(
- description="Initialize news database tables"
- )
- parser.add_argument(
- "--db-path",
- type=str,
- help="Path to the database file (default: data/shared.db)",
- )
- parser.add_argument(
- "--verify",
- action="store_true",
- help="Only verify tables without creating them",
- )
-
- args = parser.parse_args()
-
- if args.verify:
- verify_news_tables(args.db_path)
- else:
- success = init_news_tables(args.db_path)
- if success:
- logger.info("News tables initialization complete!")
- verify_news_tables(args.db_path)
- else:
- logger.error("News tables initialization failed!")
- sys.exit(1)