From a7603a296465782072ebf0a93697d7a06c75e49c Mon Sep 17 00:00:00 2001 From: Lukasz Mentel Date: Sat, 1 Jun 2024 12:25:19 +0200 Subject: [PATCH] Fix fetch_table to be compatiple across pandas and sqlalchemy versions --- mendeleev/fetch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mendeleev/fetch.py b/mendeleev/fetch.py index 5ccf7faf..6a63a173 100644 --- a/mendeleev/fetch.py +++ b/mendeleev/fetch.py @@ -2,6 +2,7 @@ import pandas as pd from sqlalchemy.dialects import sqlite +from sqlalchemy import text from mendeleev import element from mendeleev import __version__ as version @@ -65,7 +66,9 @@ def fetch_table(table: str, **kwargs) -> pd.DataFrame: ) engine = get_engine() - return pd.read_sql(table, engine, **kwargs) + query = f"SELECT * FROM {table}" + with engine.begin() as conn: + return pd.read_sql_query(sql=text(query), con=conn, **kwargs) def fetch_electronegativities(scales: List[str] = None) -> pd.DataFrame: