Skip to content

Commit

Permalink
Merge pull request #238 from gbd-consult/bug/237_error_in_the_db_sele…
Browse files Browse the repository at this point in the history
…ction

rework database selection, fix for spatialite
  • Loading branch information
Guts authored Sep 22, 2022
2 parents 233e51d + 614084e commit 0e2d2e2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions gml_application_schema_toolbox/gui/import_gmlas_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,24 +372,22 @@ def error_handler(err, err_no, msg):
"{} {}: {}".format(err, err_no, msg), __title__
)

conn = self.databaseWidget.get_database_connection
schema = None
db_format = self.databaseWidget.get_db_format
# Create temp SQLite database if no connection is selected
if conn is None:
with tempfile.NamedTemporaryFile(suffix=".sqlite") as tmp:
dest_db_name = tmp.name
provider = "SQLite"
self.plg_logger.log(f"Temp SQLite: {dest_db_name}", log_level=4)
elif self.databaseWidget.get_db_format == "postgres":
if db_format == "postgres":
dest_db_name = f"{self.databaseWidget.get_database_connection.uri()}"
schema = self.databaseWidget.selected_schema
provider = "PostgreSQL"
self.plg_logger.log(f"PostgreSQL schema: {schema}", log_level=4)
elif self.databaseWidget.get_db_format == "sqlite":
elif db_format == "sqlite" or db_format == "spatialite":
dest_db_name = self.databaseWidget.get_db_name_or_path
provider = "SQLite"
else:
return
with tempfile.NamedTemporaryFile(suffix=".sqlite") as tmp:
dest_db_name = tmp.name
provider = "SQLite"
self.plg_logger.log(f"Temp SQLite: {dest_db_name}", log_level=4)

params = self.import_params(dest_db_name, provider)

Expand Down

0 comments on commit 0e2d2e2

Please sign in to comment.