jdxi_editor.core.db.session
SQLAlchemy base and session management for JD-Xi Editor.
This module provides the declarative base and session management utilities for SQLAlchemy ORM operations.
Classes
Manages SQLAlchemy database sessions and connections. |
Module Contents
- class jdxi_editor.core.db.session.DatabaseSession(db_path: pathlib.Path | None = None)[source]
Manages SQLAlchemy database sessions and connections.
- create_indexes()[source]
Create database indexes for better query performance.
An Index attaches itself to the table definition, which is shared by every session in the process. Building new ones on each call left duplicates there, and the next session’s create_tables() on a new database failed with “index … already exists”. Existing ones are reused instead.
- create_tables()[source]
Create all database tables, and add columns that newer versions introduced to tables made by older ones.
- add_missing_columns() list[source]
Upgrade an older database in place: add each optional (nullable) column of the models that its tables lack. create_all() makes missing tables but never changes existing ones. Returns “table.column” for each column added.
- allow_songs_without_program() bool[source]
Let a playlist song have no program.
SQLite cannot relax
NOT NULLin place, so a table whoseprogram_idis still required is rebuilt. The foreign key stays: a null program matches nothing, and deleting a program still removes only the songs that use it.- Returns:
bool True when the table was rebuilt