Skip to content

fix: automatic create database directory for SQLAlchemy connector#75

Open
markoceri wants to merge 1 commit intodevfrom
fix/database-folder-not-exists-74
Open

fix: automatic create database directory for SQLAlchemy connector#75
markoceri wants to merge 1 commit intodevfrom
fix/database-folder-not-exists-74

Conversation

@markoceri
Copy link
Collaborator

Description

Following a bug report #74 , it was identified that the application crashes at startup if the /data/db directory (or any custom SQLite path) does not exist.

While the legacy SQLITE persistence adapter correctly handled directory creation, this logic was accidentally omitted during the migration to the SQLALCHEMY adapter. SQLAlchemy's SQLite engine expects the target directory to exist beforehand, leading to an OperationalError when the path is missing.

Changes

  • Re-implemented the directory presence check within the SQLALCHEMY persistence configuration.
  • Added logic to parse the db_url (specifically for sqlite:/// schemes) to extract the directory path.
  • Used os.makedirs(db_dir, exist_ok=True) to ensure the path is created safely before the repository is initialized.
  • Added debug logging to confirm directory creation during the bootstrap phase.

Testing

  • Deleted the local /data/db folder and verified that the core now creates it automatically on launch.
  • Verified that existing databases are not affected.
  • Tested with both relative and absolute paths in settings.db_path.

This PR closes #74

…tions wen using SQLAlchemy as persistence adapter
@markoceri markoceri self-assigned this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant