Python PandaSQL sqldf no such table error, but if manually execute function it will work

Viewed 191

I have some code in such a way within a .py file let's call A.py:

from B import create_dummy_df, sqldf_function

a = create_dummy_df()

query = """
select *
from a
"""

b = sqldf_function(query)

Then in another .py file (I use pycharm) let's call B.py, I have the following function defined:

from pandasql import sqldf

sqldf_function(q: str):
    foo = sqldf(q.lower(), globals())
    return foo

What I don't understand is, if I try to execute A.py file, I get an error saying no such table a, but if I manually highlight and execute sqldf_function definition code block in B.py in console, then come back and try to execute b=sqldf_function(query) in A.py, it'll work. By the way I'm using python virtual environment console for these local executions.

Thank you all in advance.

0 Answers
Related