mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
refactor: pandas.read_sql_query renamed to read_sql and can now also
directly extract full tables.
This commit is contained in:
parent
1d492dfa67
commit
de51d6ca07
2 changed files with 3 additions and 3 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue