From de51d6ca07f1a9169ada6ecc5818e0ac4e71e034 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Tue, 5 Jul 2022 13:31:41 +0100 Subject: [PATCH] refactor: pandas.read_sql_query renamed to read_sql and can now also directly extract full tables. --- pyerrors/input/pandas.py | 4 ++-- tests/pandas_test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyerrors/input/pandas.py b/pyerrors/input/pandas.py index 4b0e1d99..2aa2bfe9 100644 --- a/pyerrors/input/pandas.py +++ b/pyerrors/input/pandas.py @@ -29,7 +29,7 @@ def to_sql(df, table_name, db, if_exists='fail', gz=True): con.close() -def read_sql_query(sql, db, auto_gamma=False): +def read_sql(sql, db, auto_gamma=False): """Execute SQL query on sqlite database and obtain DataFrame including Obs or Corr valued columns. Parameters @@ -43,7 +43,7 @@ def read_sql_query(sql, db, auto_gamma=False): the error analysis. Default False. """ con = sqlite3.connect(db) - extract_df = pd.read_sql_query(sql, con) + extract_df = pd.read_sql(sql, con) con.close() return _deserialize_df(extract_df, auto_gamma=auto_gamma) diff --git a/tests/pandas_test.py b/tests/pandas_test.py index 22dc74a2..71961d38 100644 --- a/tests/pandas_test.py +++ b/tests/pandas_test.py @@ -60,7 +60,7 @@ def test_sql(tmp_path): my_db = (tmp_path / "test_db.sqlite").as_posix() pe.input.pandas.to_sql(pe_df, "My_table", my_db) for auto_gamma in [False, True]: - re_df = pe.input.pandas.read_sql_query("SELECT * from My_table", my_db, auto_gamma=auto_gamma) + re_df = pe.input.pandas.read_sql("SELECT * from My_table", my_db, auto_gamma=auto_gamma) assert np.all(re_df == pe_df)