{"record":{"id":"f4b396b404efba61","repo":"tracel-ai/burn","slug":"the-database-file-does-not-exist","errorCode":null,"errorMessage":"The database file does not exist","messagePattern":"The database file does not exist","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-dataset/src/dataset/sqlite.rs","lineNumber":474,"sourceCode":"    {\n        SqliteDatasetWriter::new(self.db_file(), overwrite)\n    }\n\n    /// Provides a reader instance for the SQLite dataset.\n    ///\n    /// # Arguments\n    ///\n    /// * `split` - A string slice that defines the data split for reading (e.g., \"train\", \"test\").\n    ///\n    /// # Returns\n    ///\n    /// * A `Result` which is `Ok` if the reader could be created, `Err` otherwise.\n    pub fn reader<I>(&self, split: &str) -> Result<SqliteDataset<I>>\n    where\n        I: Clone + Send + Sync + Serialize + DeserializeOwned,\n    {\n        if !self.exists() {\n            panic!(\"The database file does not exist\");\n        }\n\n        SqliteDataset::from_db_file(self.db_file(), split)\n    }\n}\n\n/// This `SqliteDatasetWriter` struct is a SQLite database writer dedicated to storing datasets.\n/// It retains the current writer's state and its database connection.\n///\n/// Being thread-safe, this writer can be concurrently used across multiple threads.\n///\n/// Typical applications include:\n///\n/// - Generation of a new dataset\n/// - Storage of preprocessed data or metadata\n/// - Enlargement of a dataset's item count post preprocessing\n#[derive(Debug)]\npub struct SqliteDatasetWriter<I> {","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-dataset/src/dataset/sqlite.rs#L456-L492","documentation":"`SqliteDatasetStorage::reader` panics when the sqlite database file referenced by the storage path does not exist (checked via `self.exists()`), before attempting to open it with `SqliteDataset::from_db_file`. It is a fail-fast guard so users get a clear message instead of a raw sqlite open error.","triggerScenarios":"Calling `SqliteDatasetStorage::new(path).reader::<I>(split)` (or from_df/from_dataset then reader) when the file at `path` was never created, was deleted, or the path is relative and the process's working directory differs from expected.","commonSituations":"Typos in the DB filename; running from a different cwd in a test/binary so a relative path no longer resolves; forgetting to first call `from_dataset`/`writer`/`from_df` to create the database; datasets generated by a separate preprocessing step that was skipped; artifacts cleaned by CI before the test runs.","solutions":["Check existence first with `storage.exists()` (or `Path::exists()`) and create the database (e.g. `SqliteDataset::from_dataset`, `from_df`, or `writer`) if missing.","Fix the path: use an absolute path or resolve it relative to a known base (`CARGO_MANIFEST_DIR`, env var) instead of relying on cwd.","Ensure the preprocessing/download step that produces the DB runs before the consuming code (CI ordering, feature-gated tasks).","Correct filename typos/extension mismatches (.sqlite, .db)."],"exampleFix":"// before\nlet dataset = SqliteDatasetStorage::new(\"data/train.db\").reader::<Sample>(\"train\"); // panics if missing\n\n// after\nlet storage = SqliteDatasetStorage::new(\"data/train.db\");\nassert!(storage.exists(), \"run `cargo run --bin prepare-data` first\");\nlet dataset = storage.reader::<Sample>(\"train\")?;","handlingStrategy":"validation","validationCode":"let storage = SqliteDatasetStorage::new(&db_path);\nif !storage.exists() {\n    return Err(anyhow!(\"SQLite dataset missing at {}: run the data-prep step first\", db_path.display()));\n}\nlet dataset = storage.reader::<Sample>(split)?;","typeGuard":null,"tryCatchPattern":"// panic-based; check exists() before calling reader\nif std::path::Path::new(&db_path).exists() {\n    let ds = storage.reader::<Sample>(split)?;\n}","preventionTips":["Check `storage.exists()` before every `reader()` call","Use absolute paths or paths anchored to CARGO_MANIFEST_DIR / env vars, never bare relative paths","Run/generate the sqlite dataset (from_dataset / from_df / writer) as an explicit prerequisite step in scripts and CI","Ensure the preprocessing artifact isn't gitignored/cleaned before tests that need it"],"tags":["sqlite","dataset","missing-file","burn","rust"],"backgroundTag":"file-not-found","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}