Skip to content

Confusing error message when SQLAlchemy is not installed #41237

@fredrikw

Description

@fredrikw

Trying to use read_sql_table on an instance without SQLAlchemy installed gives a confusing error message:

NotImplementedError: read_sql_table only supported for SQLAlchemy connectable.

The issue is that _is_sqlalchemy_connectable returns false if SQLAlchemy is not installed. My suggestion is to raise an error stating that SQLAlchemy is required by trying to import it directly in read_sql_table or extending the error message to say that SQLAlchemy is required. I don't know the internals and what might go wrong, but one way would be to not catch the ImportError...

pandas/pandas/io/sql.py

Lines 308 to 311 in 49c7791

if not _is_sqlalchemy_connectable(con):
raise NotImplementedError(
"read_sql_table only supported for SQLAlchemy connectable."
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementError ReportingIncorrect or improved errors from pandasIO SQLto_sql, read_sql, read_sql_query

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions