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 a8ebe550..ca527b63 100644 Binary files a/tests/data/sqlresults.db and b/tests/data/sqlresults.db differ diff --git a/tests/sorcha/test_PPOutput.py b/tests/sorcha/test_PPOutput.py index ba0220b0..40313823 100644 --- a/tests/sorcha/test_PPOutput.py +++ b/tests/sorcha/test_PPOutput.py @@ -72,7 +72,7 @@ def test_PPOutWriteSqlite3(setup_and_teardown_for_PPOutWriteSqlite3): cnx = sqlite3.connect(os.path.join(tmp_path, "test_sql_out.db")) cur = cnx.cursor() - cur.execute("select * from pp_results") + cur.execute("select * from sorcha_results") col_names = list(map(lambda x: x[0], cur.description)) test_in = pd.DataFrame(cur.fetchall(), columns=col_names) @@ -121,7 +121,7 @@ def test_PPWriteOutput(setup_and_teardown_for_PPWriteOutput): PPWriteOutput(args, configs, observations, 10) cnx = sqlite3.connect(os.path.join(tmp_path, "PPOutput_test_out.db")) cur = cnx.cursor() - cur.execute("select * from pp_results") + cur.execute("select * from sorcha_results") col_names = list(map(lambda x: x[0], cur.description)) sql_test_in = pd.DataFrame(cur.fetchall(), columns=col_names) diff --git a/tests/sorcha/test_createResultsSQLDatabase.py b/tests/sorcha/test_createResultsSQLDatabase.py index 83c1da7f..6541eae8 100644 --- a/tests/sorcha/test_createResultsSQLDatabase.py +++ b/tests/sorcha/test_createResultsSQLDatabase.py @@ -91,7 +91,7 @@ def test_create_results_table(tmp_path): cnx_in = sqlite3.connect(os.path.join(tmp_path, "test_results_table.db")) cur = cnx_in.cursor() - cur.execute("select * from pp_results") + cur.execute("select * from sorcha_results") col_names = list(map(lambda x: x[0], cur.description)) test_inputs = pd.DataFrame(cur.fetchall(), columns=col_names) cnx_out.close() @@ -125,7 +125,7 @@ def test_create_results_database(tmp_path): col_names = list(map(lambda x: x[0], cur.description)) test_orbits = pd.DataFrame(cur.fetchall(), columns=col_names) - cur.execute("select * from pp_results") + cur.execute("select * from sorcha_results") col_names = list(map(lambda x: x[0], cur.description)) test_results = pd.DataFrame(cur.fetchall(), columns=col_names)