mafw.steering_gui.views.database_editor
Expose the database editor UI for steering file configuration.
- Author:
Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)
- Description:
Provide a widget to edit database backend, transport, authentication, and backend parameters without touching the builder.
Module Attributes
Default backend selection for the database editor. |
|
Mapping of backend identifiers to URL prefixes. |
|
Default SQLite pragma values used for parameter seeding. |
|
Default service ports used by server backends. |
|
Placeholder URL examples for each backend. |
Classes
|
Widget exposing authentication configuration for server databases. |
|
Widget that exposes database backend selection and layered configuration. |
|
Widget that manages backend-specific parameters. |
|
Widget exposing the database transport layer (URL). |
- class mafw.steering_gui.views.database_editor.AuthenticationWidget(parent: QWidget | None = None)[source]
Bases:
QWidgetWidget exposing authentication configuration for server databases.
- has_required_fields() bool[source]
Return whether required fields for the selected method are populated.
- set_data(auth: Mapping[str, Any] | None) None[source]
Populate widget values from the auth mapping.
- property file_browse_button: QToolButton
Expose browse button for tests.
- property file_edit: QLineEdit
Expose password file edit for tests.
- property method_combo: QComboBox
Expose method combo for tests.
- property password_edit: QLineEdit
Expose password edit for tests.
- property username_edit: QLineEdit
Expose username edit for tests.
- class mafw.steering_gui.views.database_editor.DatabaseEditor(parent: QWidget | None = None)[source]
Bases:
QWidgetWidget that exposes database backend selection and layered configuration.
- _detect_backend_from_url(url: str | None) str[source]
Determine the backend type from the given URL.
This method analyses the provided URL to identify the corresponding backend type by matching URL prefixes or extracting the protocol. If no match is found, it defaults to the current backend or the default backend.
- Parameters:
url – The URL string to be analysed for backend detection.
- Returns:
A string representing the detected backend type.
- _normalize_config(config: dict[str, Any] | None) dict[str, Any][source]
Normalize the configuration dictionary to ensure consistent backend, URL, authentication, and parameters.
This method processes the input configuration dictionary to extract and normalize values for backend type, URL, authentication details, and backend-specific parameters, ensuring defaults are applied where necessary.
- Parameters:
config – A dictionary containing configuration details such as backend, URL, authentication, and parameters. If None, defaults are applied.
- Returns:
A dictionary with normalized configuration values including backend, URL, enabled status, authentication, parameters, and pragmas.
- class mafw.steering_gui.views.database_editor.ParametersWidget(parent: QWidget | None = None)[source]
Bases:
QWidgetWidget that manages backend-specific parameters.
- set_data(parameters: Mapping[str, Mapping[str, Any]] | None, backend: str) None[source]
Populate the widget with the provided backend parameter mapping.
- property table: QTableView
Expose the parameter table for tests.
- class mafw.steering_gui.views.database_editor.TransportWidget(parent: QWidget | None = None)[source]
Bases:
QWidgetWidget exposing the database transport layer (URL).
- property sqlite_memory_button: QToolButton
Expose the SQLite memory button for tests.
- property sqlite_open_button: QToolButton
Expose the SQLite open button for tests.
- property url_edit: QLineEdit
Expose the active URL edit widget for external tests.
- mafw.steering_gui.views.database_editor.DEFAULT_BACKEND = 'sqlite'
Default backend selection for the database editor.
- mafw.steering_gui.views.database_editor.DEFAULT_PRAGMAS: dict[str, Any] = {'cache_size': -64000, 'foreign_keys': 1, 'journal_mode': 'wal', 'synchronous': 0}
Default SQLite pragma values used for parameter seeding.
- mafw.steering_gui.views.database_editor.DEFAULT_SERVER_PORTS: dict[str, int] = {'mysql': 3306, 'postgresql': 5432}
Default service ports used by server backends.
- mafw.steering_gui.views.database_editor.DEFAULT_URLS: dict[str, str] = {'mysql': 'mysql://', 'postgresql': 'postgresql://', 'sqlite': 'sqlite:///'}
Mapping of backend identifiers to URL prefixes.
- mafw.steering_gui.views.database_editor.DEFAULT_URL_PLACEHOLDERS: dict[str, str] = {'mysql': 'mysql://localhost:3306/mydb', 'postgresql': 'postgresql://localhost:5432/mydb', 'sqlite': 'sqlite:////path/to/db'}
Placeholder URL examples for each backend.