The problem seems to be with how sqlalchemy interacts with the pd.read_sql_query function in pandas. It seems like in SQLAlchemy2.0, we need to pass in a connection object rather than an engine object into pd.read_sql_query. In addition, it seems like we cannot pass in the raw query string directly into pd.read_sql_query, but should wrap it with the text method from sqlalchemy. The place in the code where it errors out seems to be here: https://github.com/defog-ai/sql-eval/blob/main/eval/eval.py#L223-L225
When I run the following:
pd.read_sql_query(text(query), engine)
I get the same errors as above. However, when I run the following:
Hi there, I would recommend using the packages in requirements.txt. Specifically, you should psycopg2 instead of psycopg. You can do this with pip install --upgrade psycopg2-binary
I'm having trouble getting the
compare_query_results
function to work with my local postgres database while usingpsycopg
. When I run something like:I get the following error:
Looking into the above, the error seems to be coming from sqlalchemy. When I downgrade to sqlalchemy<2.0.0, I instead get the following:
The problem seems to be with how sqlalchemy interacts with the
pd.read_sql_query
function in pandas. It seems like in SQLAlchemy2.0, we need to pass in a connection object rather than an engine object intopd.read_sql_query
. In addition, it seems like we cannot pass in the raw query string directly intopd.read_sql_query
, but should wrap it with thetext
method from sqlalchemy. The place in the code where it errors out seems to be here: https://github.com/defog-ai/sql-eval/blob/main/eval/eval.py#L223-L225When I run the following:
I get the same errors as above. However, when I run the following:
I get results as expected.
Here are my relevant package versions: