add database feature#381
Conversation
|
I took a pass over this PR and I think it’s close, but I’d request a couple of changes before merging. First, the crawler behavior regressed a bit: relative links like /relative/path are now being treated as crawlable child URLs instead of being filtered out. That breaks the existing expectation in the linktree tests and makes the tree include nodes that probably shouldn’t be there. Second, the new installed entry point looks a bit brittle. The wrapper in cli.py imports toml directly and also assumes the repo root is on sys.path, which can break in a clean wheel install. I verified that invoking torbot --help from a fresh venv after installing the built wheel fails with ModuleNotFoundError: No module named 'toml'. So overall: the CLI idea is good, but I’d like to see the relative-link filtering fixed and the installed entry point made more robust before this gets merged. |
Issue #315
Changes Proposed
Added database as a new choice for the --save argument
Location: main.py lines 138-139
Created src/torbot/modules/database.py
Implements SearchResultsDatabase class for SQLite management
No external database server required (uses built-in sqlite3)
Added saveDatabase() method in src/torbot/modules/linktree.py (lines 159-195)
Extracts all discovered links and metadata for persistent storage
Created src/torbot/modules/db_query.py for result retrieval
Created scripts/query_database.py CLI for database operations
Explanation of Changes
Database Engine & Architecture
SQLite (file-based, no server)<project_root>/torbot_search_results.db
Auto-initialized on first use
Database Schema
searches Table (Search Metadata)
links Table (Individual Link Records)
Relationship: One search has many links (1:N relationship with CASCADE delete)
Metadata Captured Per Search
Root-Level Metadata:
✅ Root URL being crawled
✅ Exact timestamp of search (ISO 8601)
✅ Crawl depth configuration
✅ Total link count
Per-Link Metadata:
✅ Full URL
✅ Page title
✅ HTTP status code (connectivity indicator)
✅ Content classification (marketplace, forum, etc.)
✅ Classification accuracy/confidence
✅ Email addresses extracted
✅ Phone numbers extracted
Core Features:
Usage
Basic Save:
Benefits: