From 312cb4b67fd748ac239f915f8cb7ecbf3453b490 Mon Sep 17 00:00:00 2001 From: Antti Soininen Date: Fri, 7 Feb 2025 13:30:35 +0200 Subject: [PATCH] Replace deprecated use of URL() by URL.create() Re spine-tools/Spine-Database-API#477 --- spinetoolbox/spine_db_editor/widgets/custom_qwidgets.py | 2 +- spinetoolbox/spine_db_editor/widgets/spine_db_editor.py | 2 +- spinetoolbox/spine_db_manager.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spinetoolbox/spine_db_editor/widgets/custom_qwidgets.py b/spinetoolbox/spine_db_editor/widgets/custom_qwidgets.py index a36415b41..9d2474252 100644 --- a/spinetoolbox/spine_db_editor/widgets/custom_qwidgets.py +++ b/spinetoolbox/spine_db_editor/widgets/custom_qwidgets.py @@ -146,7 +146,7 @@ class OpenSQLiteFileButton(OpenFileButton): def __init__(self, file_path, progress, db_editor): super().__init__(file_path, progress, db_editor) - self.url = URL("sqlite", database=self.file_path) + self.url = URL.create("sqlite", database=self.file_path) @Slot(bool) def open_file(self, checked=False): diff --git a/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py b/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py index fd647cb0c..fc63184ae 100644 --- a/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py +++ b/spinetoolbox/spine_db_editor/widgets/spine_db_editor.py @@ -430,7 +430,7 @@ def import_from_json(self, file_path): self.msg.emit(f"File {filename} successfully imported.") def import_from_sqlite(self, file_path): - url = URL("sqlite", database=file_path) + url = URL.create("sqlite", database=file_path) filename = os.path.split(file_path)[1] try: db_map = DatabaseMapping(url) diff --git a/spinetoolbox/spine_db_manager.py b/spinetoolbox/spine_db_manager.py index 25df18aa3..dbc539231 100644 --- a/spinetoolbox/spine_db_manager.py +++ b/spinetoolbox/spine_db_manager.py @@ -1654,7 +1654,7 @@ def _is_url_available(self, url, logger): def export_to_sqlite(self, file_path, data_for_export, caller): """Exports given data into SQLite file.""" - url = URL("sqlite", database=file_path) + url = URL.create("sqlite", database=file_path) if not self._is_url_available(url, caller): return with DatabaseMapping(url, create=True) as db_map: @@ -1679,7 +1679,7 @@ def export_to_json(file_path, data_for_export, caller): def export_to_excel(file_path, data_for_export, caller): """Exports given data into Excel file.""" # NOTE: We import data into an in-memory Spine db and then export that to excel. - url = URL("sqlite", database="") + url = URL.create("sqlite", database="") with DatabaseMapping(url, create=True) as db_map: count, errors = import_data(db_map, **data_for_export, unparse_value=dump_db_value) file_name = os.path.split(file_path)[1]