From ef35b5e8ef401fa2d9afad4b1af636c44071def3 Mon Sep 17 00:00:00 2001 From: Jarian Cottingham Date: Mon, 2 Feb 2026 21:33:57 -0600 Subject: [PATCH] Fix database initialization - add directory creation for database file --- factsdb/database.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/factsdb/database.py b/factsdb/database.py index 97aba5f..4d9a6f6 100644 --- a/factsdb/database.py +++ b/factsdb/database.py @@ -21,7 +21,20 @@ class DatabaseManager: self._init_database() except Exception as e: print(f"Warning: Database initialization failed: {e}") - # Continue with minimal functionality or raise the error + # Create the directory if it doesn't exist and the path has a directory component + import os + try: + # Check if path has a directory component + if os.path.dirname(self.config.path): + os.makedirs(os.path.dirname(self.config.path), exist_ok=True) + print(f"Created directory for database: {os.path.dirname(self.config.path)}") + else: + # If no directory, ensure current directory is writable + os.makedirs('.', exist_ok=True) + print("Verified current directory is writable") + except Exception as dir_error: + print(f"Warning: Could not create database directory: {dir_error}") + # Re-raise the original error raise def _init_database(self):