unclecode/crawl4ai · error · ValueError
Database path is not set or is empty.
Error message
Database path is not set or is empty.
What it means
Error "Database path is not set or is empty." thrown in unclecode/crawl4ai.
Source
Thrown at crawl4ai/legacy/database.py:51
def alter_db_add_screenshot(new_column: str = "media"):
check_db_path()
try:
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
cursor.execute(
f'ALTER TABLE crawled_data ADD COLUMN {new_column} TEXT DEFAULT ""'
)
conn.commit()
conn.close()
except Exception as e:
print(f"Error altering database to add screenshot column: {e}")
def check_db_path():
if not DB_PATH:
raise ValueError("Database path is not set or is empty.")
def get_cached_url(
url: str,
) -> Optional[Tuple[str, str, str, str, str, str, str, bool, str]]:
check_db_path()
try:
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
cursor.execute(
"SELECT url, html, cleaned_html, markdown, extracted_content, success, media, links, metadata, screenshot FROM crawled_data WHERE url = ?",
(url,),
)
result = cursor.fetchone()
conn.close()
return result
except Exception as e:
print(f"Error retrieving cached URL: {e}")View on GitHub (pinned to 7e80152142)
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.
Example fix
db = Database(); db.set_path(os.path.expanduser('~/.crawl4ai/crawl4ai.db')) When it happens
Trigger: Thrown at crawl4ai/legacy/database.py:51 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of unclecode/crawl4ai@7e80152142 (2026-08-14).
Data as JSON: /api/errors/5bf9d6d9c74a0a85.
Report an issue: GitHub.