(output_file: Path)
| 170 | |
| 171 | |
| 172 | def _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 | |
| 194 | def _restore_sqlite(dump_file: Path) -> None: |
no test coverage detected