{"record":{"id":"5bf9d6d9c74a0a85","repo":"unclecode/crawl4ai","slug":"database-path-is-not-set-or-is-empty","errorCode":null,"errorMessage":"Database path is not set or is empty.","messagePattern":"Database path is not set or is empty\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crawl4ai/legacy/database.py","lineNumber":51,"sourceCode":"\n\ndef alter_db_add_screenshot(new_column: str = \"media\"):\n    check_db_path()\n    try:\n        conn = sqlite3.connect(DB_PATH)\n        cursor = conn.cursor()\n        cursor.execute(\n            f'ALTER TABLE crawled_data ADD COLUMN {new_column} TEXT DEFAULT \"\"'\n        )\n        conn.commit()\n        conn.close()\n    except Exception as e:\n        print(f\"Error altering database to add screenshot column: {e}\")\n\n\ndef check_db_path():\n    if not DB_PATH:\n        raise ValueError(\"Database path is not set or is empty.\")\n\n\ndef get_cached_url(\n    url: str,\n) -> Optional[Tuple[str, str, str, str, str, str, str, bool, str]]:\n    check_db_path()\n    try:\n        conn = sqlite3.connect(DB_PATH)\n        cursor = conn.cursor()\n        cursor.execute(\n            \"SELECT url, html, cleaned_html, markdown, extracted_content, success, media, links, metadata, screenshot FROM crawled_data WHERE url = ?\",\n            (url,),\n        )\n        result = cursor.fetchone()\n        conn.close()\n        return result\n    except Exception as e:\n        print(f\"Error retrieving cached URL: {e}\")","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/legacy/database.py#L33-L69","documentation":"Error \"Database path is not set or is empty.\" thrown in unclecode/crawl4ai.","triggerScenarios":"Thrown at crawl4ai/legacy/database.py:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set a valid database path before using the database (e.g. db.set_path('crawl4ai.db')).","Ensure the path string is non-empty and the directory exists."],"exampleFix":"db = Database(); db.set_path(os.path.expanduser('~/.crawl4ai/crawl4ai.db'))","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}