Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

df = fetch_table('elements') its not working its showing the error AttributeError: 'OptionEngine' object has no attribute 'execute' #158

Closed
93-hsngit opened this issue May 27, 2024 · 11 comments · Fixed by #159
Assignees
Labels
bug Something isn't working

Comments

@93-hsngit
Copy link

93-hsngit commented May 27, 2024

Describe the bug

from mendeleev.fetch import fetch_table
from mendeleev.db import get_session, get_engine

df = fetch_table('elements')

AttributeError: 'OptionEngine' object has no attribute 'execute'

@93-hsngit 93-hsngit added the bug Something isn't working label May 27, 2024
@93-hsngit
Copy link
Author

AttributeError: 'OptionEngine' object has no attribute 'execute'

@93-hsngit 93-hsngit changed the title df = fetch_table('elements') its not working its showing the df = fetch_table('elements') its not working its showing the error May 27, 2024
@93-hsngit 93-hsngit changed the title df = fetch_table('elements') its not working its showing the error df = fetch_table('elements') its not working its showing the error AttributeError: 'OptionEngine' object has no attribute 'execute' May 27, 2024
@lmmentel
Copy link
Owner

Thanks @93-hsngit, could you say what version of mendeleev you are using?

@lmmentel
Copy link
Owner

I just tried to reproduce with the latest version (0.16.2) and didn't get any errors:

In [1]: from mendeleev.fetch import fetch_table, get_engine

In [2]: df = fetch_table("elements")

In [3]: df.head()
Out[3]: 
                                          annotation  atomic_number  atomic_radius  atomic_volume block  ...  mendeleev_number dipole_polarizability_unc  pettifor_number  glawe_number molar_heat_capacity
0  density(@ -253C), evaporation_heat(H-H), fusio...              1           25.0           14.1     s  ...               105                   0.00003            103.0         103.0              28.836
1                                 density(@ -270C),               2          120.0           31.8     s  ...               112                   0.00002              1.0           1.0              20.786
2                                                                 3          145.0           13.1     s  ...                 1                   0.00050             12.0          12.0              24.860
3                                                                 4          105.0            5.0     s  ...                75                   0.03000             77.0          77.0              16.443
4                                                                 5           85.0            4.6     p  ...                81                   0.10000             86.0          86.0              11.087

[5 rows x 69 columns]

In [4]: import mendeleev

In [5]: mendeleev.__version__
Out[5]: '0.16.2'

@93-hsngit
Copy link
Author

93-hsngit commented May 27, 2024 via email

@lmmentel
Copy link
Owner

lmmentel commented May 27, 2024

Just to be sure, could you share what the following code produces with your installation:

import mendeleev
import sqlalchemy
import pandas
print(f"{mendeleev.__version__=}")
print(f"{sqlalchemy.__version__=}")
print(f"{pandas.__version__=}")

@lmmentel
Copy link
Owner

lmmentel commented May 27, 2024

I googled around and discovered this might be related to sqlachemy version. I cannot reproduce your exact error but when I downgraded to sqlalchemy==1.4.52 I get this:

from mendeleev.fetch import fetch_table, get_engine
df = fetch_table("elements")
...
AttributeError: 'Engine' object has no attribute 'cursor'

which seems to be a known issue with pandas and sqlalchemy pandas-dev/pandas#57049.

When you get a chance please share the versions of packages you're using, see previous comment #158 (comment)

@93-hsngit
Copy link
Author

93-hsngit commented May 28, 2024 via email

@lmmentel
Copy link
Owner

lmmentel commented May 28, 2024

@93-hsngit there is no image attached to your comment, maybe something went wrong?

Right now I cannot reproduce your specific error and my suspicion is that it's something to do with dependencies so please share the output of running #158 (comment)

@93-hsngit
Copy link
Author

mendeleev.version='0.16.2'
sqlalchemy.version='2.0.25'
pandas.version='1.5.3'

@lmmentel
Copy link
Owner

lmmentel commented Jun 1, 2024

Thanks @93-hsngit, I was able to reproduce the same error with the combination of dependencies you shared.

I started working on a solution in #159 but it might take some time to test against relevant versions of dependencies. Overall this seems like a mismatch between major version of pandas and sqlalchemy but I hope I can find an api consistent between the version changes.

In the meantime you could upgrade your pandas versions to ">=2.0.0" and that should solve it for you.

@93-hsngit
Copy link
Author

Yahh..., now the problem get resolve after installing pandas==2.0.0, Thank you so much @lmmentel Love your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants