{"record":{"id":"ed0498cd002cc532","repo":"pathwaycom/pathway","slug":"path-path-str-r-is-an-existing-directory-not-a","errorCode":null,"errorMessage":"path {path_str!r} is an existing directory, not a SQLite database file. SQLite cannot open a directory as a database; pass a file path instead.","messagePattern":"path (.+?) is an existing directory, not a SQLite database file\\. SQLite cannot open a directory as a database; pass a file path instead\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/sqlite/__init__.py","lineNumber":34,"sourceCode":"from pathway.internals.trace import trace_user_frame\nfrom pathway.io._utils import (\n    SNAPSHOT_OUTPUT_TABLE_TYPE,\n    get_column_index,\n    init_mode_from_str,\n    read_schema,\n)\n\n\ndef _reject_directory_path(path_str: str) -> None:\n    \"\"\"Reject ``path`` that resolves to an existing directory (directly\n    or via symlink). Without this preflight the underlying ``rusqlite``\n    call returns the opaque ``disk I/O error`` (read) or ``unable to\n    open database file`` (write) at flush time, panicking an engine\n    worker. ``os.path.isdir`` follows symlinks, so this also catches a\n    symlink-to-directory.\n    \"\"\"\n    if os.path.isdir(path_str):\n        raise ValueError(\n            f\"path {path_str!r} is an existing directory, not a SQLite \"\n            \"database file. SQLite cannot open a directory as a database; \"\n            \"pass a file path instead.\"\n        )\n\n\n@check_arg_types\n@trace_user_frame\ndef read(\n    path: PathLike | str,\n    table_name: str,\n    schema: type[Schema],\n    *,\n    autocommit_duration_ms: int | None = 1500,\n    name: str | None = None,\n    max_backlog_size: int | None = None,\n    debug_data: Any = None,\n) -> Table:","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/sqlite/__init__.py#L16-L52","documentation":"Raised by the Pathway SQLite connector's read/write preflight when the path argument resolves to an existing directory (directly or through a symlink). rusqlite cannot open a directory as a database; without this check it would fail much later with an opaque 'disk I/O error' or 'unable to open database file' that panics an engine worker, so Pathway rejects the path eagerly with an actionable message.","triggerScenarios":"Passing a directory path to pw.io.sqlite.read/write, e.g. path='data/' or path='.'; passing a symlink that points to a directory; building the path with os.path.join where the filename component ended up empty (path equal to the directory itself).","commonSituations":"Trailing-slash or bare-directory arguments meant to mean 'the db in this folder'; path templates where the database filename variable is empty; symlinks in deployment directories that point at folders; confusing the SQLite file connector with directory-based formats like csv.","solutions":["Pass the actual database file path, e.g. 'data/app.db' instead of 'data/'.","Check the variable used for the filename: ensure it is non-empty and ends with the .db/.sqlite filename you expect.","If path comes from user input, guard with os.path.isdir(path) and surface a clear configuration error before calling read/write."],"exampleFix":"# before\npw.io.sqlite.read(\"data/\", \"users\", schema=S)  # data/ is a directory\n\n# after\npw.io.sqlite.read(\"data/app.db\", \"users\", schema=S)","handlingStrategy":"validation","validationCode":"import os\nif os.path.isdir(path):\n    raise ValueError(f\"{path!r} is a directory; pass the .db file path\")\npw.io.sqlite.read(path, \"users\", schema=S)","typeGuard":"def is_sqlite_file_path(p) -> bool:\n    import os\n    return not os.path.isdir(p)","tryCatchPattern":null,"preventionTips":["Always pass the full filename, not the containing directory.","Watch for trailing slashes and empty filename variables in f-string paths.","Remember the check follows symlinks — a symlink to a directory is also rejected."],"tags":["pathway","sqlite","filesystem","path","configuration"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}