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

Installing trino[sqlalchemy] wont allow pandas.read_sql #352

Closed
1 task done
GitToby opened this issue Apr 5, 2023 · 3 comments
Closed
1 task done

Installing trino[sqlalchemy] wont allow pandas.read_sql #352

GitToby opened this issue Apr 5, 2023 · 3 comments

Comments

@GitToby
Copy link

GitToby commented Apr 5, 2023

Expected behavior

Running a pandas.read_sql or similar fails with AttributeError: 'OptionEngine' object has no attribute 'execute'

Actual behavior

Running a pandas.read_sql or similar should return dataframe with the table results.

Steps To Reproduce

install with trino[sqlalchemy] then run

engine = create_engine(
    "trino://my.instance:443/abcd",
    connect_args={
        "user": user_,
        "auth": BasicAuthentication(user_, pass_),
        "http_scheme": "https",
        "verify": "path/to/bundle.cer",
        # ...
    }
)
df = pd.read_sql("SELECT * FROM system.runtime.nodes", engine)

This is due to the optional dependancy not limiting the sqlalchemt version and hence falls victim to this bug: pandas-dev/pandas#51015

A fix would be to limit the version to sqlalchemy<2.0.0

Log output

No response

Operating System

macos

Trino Python client version

0.322.0

Trino Server version

na

Python version

3.11

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@GitToby
Copy link
Author

GitToby commented Apr 5, 2023

a fix is to add the dependencies

  • "trino>=0.322.0"
  • "sqlalchemy<2.0.0"

after install this should push the sqlalchemy down and the pandas methods will work.

@GitToby GitToby mentioned this issue Apr 5, 2023
@hashhar
Copy link
Member

hashhar commented Apr 6, 2023

This is something that users of this package need to do. They can add explicit constraint for sqlalchemy. In case pandas doesn't work with sqlalchemy 2.x pandas should add the constraint and then pip would automatically resolve to a working version.

Alternatively use pandas 2.0 which works with sqlalchemy 2.x

@hashhar hashhar closed this as completed Apr 6, 2023
@GitToby
Copy link
Author

GitToby commented Apr 7, 2023

at the time of writing pandas 2.0 was released 3 days ago and is not really stable. I suppose this can be skipped internally to the Trino Python client, maybe documentation is a better approach for those who run into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants