From be74fc9b72219ec6f7f7aa6ac6e4517019b71a52 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Thu, 12 Sep 2024 16:28:04 +0545 Subject: [PATCH 1/3] fix(appcustom): custom exports set srs --- src/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.py b/src/app.py index 795f9675..7f2a22a8 100644 --- a/src/app.py +++ b/src/app.py @@ -1462,7 +1462,7 @@ def process_export_format(export_format): else "" ) if USE_DUCK_DB_FOR_CUSTOM_EXPORTS is True: - executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f', LAYER_CREATION_OPTIONS {layer_creation_options_str}' if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})""" + executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f', SRS 4326, LAYER_CREATION_OPTIONS {layer_creation_options_str}' if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})""" self.duck_db_instance.run_query( executable_query.strip(), load_spatial=True ) From da0a59760103c7e42fabcd60bb9b6637a1f873cd Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Thu, 12 Sep 2024 17:10:13 +0545 Subject: [PATCH 2/3] Fix syntax issue --- src/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.py b/src/app.py index 7f2a22a8..8181e9d4 100644 --- a/src/app.py +++ b/src/app.py @@ -1462,7 +1462,7 @@ def process_export_format(export_format): else "" ) if USE_DUCK_DB_FOR_CUSTOM_EXPORTS is True: - executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f', SRS 4326, LAYER_CREATION_OPTIONS {layer_creation_options_str}' if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})""" + executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f", SRS 'EPSG:4326', LAYER_CREATION_OPTIONS {layer_creation_options_str}" if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})""" self.duck_db_instance.run_query( executable_query.strip(), load_spatial=True ) From 14e6eda65caa90a4d7c921df046a3dc452e2ec73 Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Thu, 12 Sep 2024 17:20:28 +0545 Subject: [PATCH 3/3] fix syntax issue --- src/app.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app.py b/src/app.py index 8181e9d4..633d1d1a 100644 --- a/src/app.py +++ b/src/app.py @@ -1462,7 +1462,22 @@ def process_export_format(export_format): else "" ) if USE_DUCK_DB_FOR_CUSTOM_EXPORTS is True: - executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f", SRS 'EPSG:4326', LAYER_CREATION_OPTIONS {layer_creation_options_str}" if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})""" + + format_option = export_format.format_option + + driver_and_layer_options = "" + if format_option == "GDAL": + driver_and_layer_options = f", DRIVER '{export_format.driver_name}'" + if layer_creation_options_str: + driver_and_layer_options += f", SRS 'EPSG:4326', LAYER_CREATION_OPTIONS {layer_creation_options_str}" + + executable_query = f""" + COPY ({query.strip()}) + TO '{export_file_path}' + WITH (FORMAT {format_option}{driver_and_layer_options}) + """ + + # executable_query = f"""COPY ({query.strip()}) TO '{export_file_path}' WITH (FORMAT {export_format.format_option}{f", DRIVER '{export_format.driver_name}'{f", SRS 'EPSG:4326', LAYER_CREATION_OPTIONS {layer_creation_options_str}" if layer_creation_options_str else ''}" if export_format.format_option == 'GDAL' else ''})""" self.duck_db_instance.run_query( executable_query.strip(), load_spatial=True )