MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / _dump_sqlite

Function _dump_sqlite

apps/backups/services.py:172–191  ·  view source on GitHub ↗
(output_file: Path)

Source from the content-addressed store, hash-verified

170
171
172def _dump_sqlite(output_file: Path) -> None:
173 import sqlite3 as _sqlite3
174 logger.info("Dumping SQLite database...")
175 db_path = Path(settings.DATABASES["default"]["NAME"])
176
177 if not db_path.exists():
178 raise FileNotFoundError(f"SQLite database not found: {db_path}")
179
180 src = _sqlite3.connect(str(db_path))
181 dst = _sqlite3.connect(str(output_file))
182 try:
183 src.backup(dst)
184 finally:
185 dst.close()
186 src.close()
187
188 if not output_file.exists():
189 raise RuntimeError("SQLite backup failed: output file not created")
190
191 logger.info(f"SQLite backup completed successfully: {output_file}")
192
193
194def _restore_sqlite(dump_file: Path) -> None:

Callers 1

create_backupFunction · 0.85

Calls 3

connectMethod · 0.80
existsMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected