From c9a38e3da3ce76fd3926c70769970079f1aa9f83 Mon Sep 17 00:00:00 2001 From: Steph Merritt Date: Tue, 9 Apr 2024 16:38:32 +0100 Subject: [PATCH] Changing name of results SQL database table. --- src/sorcha/modules/PPOutput.py | 5 ++++- .../utilities/createResultsSQLDatabase.py | 10 +++++----- tests/data/sqlresults.db | Bin 57344 -> 57344 bytes tests/sorcha/test_PPOutput.py | 4 ++-- tests/sorcha/test_createResultsSQLDatabase.py | 4 ++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/sorcha/modules/PPOutput.py b/src/sorcha/modules/PPOutput.py index c4c56e23..3bc397dc 100755 --- a/src/sorcha/modules/PPOutput.py +++ b/src/sorcha/modules/PPOutput.py @@ -82,12 +82,15 @@ def PPOutWriteSqlite3(pp_results, outf): None. """ + pplogger = logging.getLogger(__name__) pp_results = pp_results.drop("level_0", axis=1, errors="ignore") cnx = sqlite3.connect(outf) - pp_results.to_sql("pp_results", con=cnx, if_exists="append", index=False) + pp_results.to_sql("sorcha_results", con=cnx, if_exists="append", index=False) + + pplogger.info("SQL results saved in table sorcha_results in database {}.".format(outf)) def PPWriteOutput(cmd_args, configs, observations_in, endChunk=0, verbose=False): diff --git a/src/sorcha/utilities/createResultsSQLDatabase.py b/src/sorcha/utilities/createResultsSQLDatabase.py index 8245b13f..a8c58f91 100644 --- a/src/sorcha/utilities/createResultsSQLDatabase.py +++ b/src/sorcha/utilities/createResultsSQLDatabase.py @@ -16,7 +16,7 @@ from sorcha.modules.PPConfigParser import PPFindDirectoryOrExit -def create_results_table(cnx_out, filename, output_path, output_stem, table_name="pp_results"): +def create_results_table(cnx_out, filename, output_path, output_stem, table_name="sorcha_results"): """ Creates a table in a SQLite database from SSPP results. @@ -35,7 +35,7 @@ def create_results_table(cnx_out, filename, output_path, output_stem, table_name stem filename for SSPP outputs. table_name : string, optional - name of table of for storing sorcha results. Default ="pp_results" + name of table of for storing sorcha results. Default ="sorcha_results" Returns ----------- @@ -71,7 +71,7 @@ def create_results_table(cnx_out, filename, output_path, output_stem, table_name con = sqlite3.connect(filename) cur = con.cursor() - cur.execute("SELECT * FROM pp_results") + cur.execute("SELECT * FROM sorcha_results") output = cur.fetchall() for row in output: @@ -156,7 +156,7 @@ def create_results_database(args): create_inputs_table(cnx_out, "comet") -def get_column_names(filename, table_name="pp_results"): +def get_column_names(filename, table_name="sorcha_results"): """ Obtains column names from a table in a SQLite database. @@ -166,7 +166,7 @@ def get_column_names(filename, table_name="pp_results"): Filepath/name of sqlite3 database. table_name : string, optional - Name of table. Default = "pp_results" + Name of table. Default = "sorcha_results" Returns ----------- diff --git a/tests/data/sqlresults.db b/tests/data/sqlresults.db index a8ebe5507a092fb74997c971b6743318bee54997..ca527b63c41d008a38f2478f9aed4cda67736b00 100644 GIT binary patch delta 87 zcmZoTz}#?vc|sP8F9Vlsl}x^CB>*b aCg&hm#}HSA5Jx8;R|O@A