MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / __init__

Method __init__

db_manager.py:84–108  ·  view source on GitHub ↗

Initialize the database manager. Args: db_path: Path to SQLite database file (default: data/ragnar.db) currentdir: Root directory of Ragnar installation

(self, db_path: str = None, currentdir: str = None, data_root: str = None)

Source from the content-addressed store, hash-verified

82 """
83
84 def __init__(self, db_path: str = None, currentdir: str = None, data_root: str = None):
85 """
86 Initialize the database manager.
87
88 Args:
89 db_path: Path to SQLite database file (default: data/ragnar.db)
90 currentdir: Root directory of Ragnar installation
91 """
92 self.currentdir = currentdir or os.path.dirname(os.path.abspath(__file__))
93 self.datadir = data_root or os.path.join(self.currentdir, 'data')
94
95 # Database file location
96 if db_path is None:
97 db_path = os.path.join(self.datadir, 'ragnar.db')
98
99 self.db_path = db_path
100 self.lock = threading.RLock() # Reentrant lock for nested calls
101
102 # Legacy CSV paths for migration
103 self.netkb_csv = os.path.join(self.datadir, 'netkb.csv')
104
105 # Initialize database
106 self._init_database()
107
108 logger.info(f"DatabaseManager initialized: {self.db_path}")
109
110 def configure_storage(self, data_root: Optional[str], db_path: Optional[str]):
111 """Update the storage root and database path when network context changes."""

Callers

nothing calls this directly

Calls 2

_init_databaseMethod · 0.95
infoMethod · 0.80

Tested by

no test coverage detected