Skip to content

AttributeError during pd.read_sql_table #278

Open
@r-nasc

Description

@r-nasc

SQLAlchemy version: 1.4.22
databricks-sql-connector version: 2.9.3

The following code throws the error below:

from sqlalchemy import create_engine
[...]
conn = create_engine(
    f"databricks://token:{token}@{host}?http_path={path}"
    "&catalog={catalog}&schema={schema}"
)
test = pd.read_sql_table(table, con=conn)

File "[REDACTED]\sqlalchemy\engine\reflection.py", line 266, in get_table_names
return self.dialect.get_table_names(
File "[REDACTED]\databricks\sqlalchemy\dialect_init_.py", line 247, in get_table_names
with self.get_connection_cursor(connection) as cur:
File "[REDACTED]\databricks\sqlalchemy\dialect_init_.py", line 299, in get_connection_cursor
return connection._dbapi_connection.dbapi_connection.cursor()
File "[REDACTED]\sqlalchemy\pool\base.py", line 985, in getattr
return getattr(self.connection, key)
AttributeError: 'Connection' object has no attribute 'dbapi_connection'

I believe the line linked below should read connection._dbapi_connection.cursor() (attr exists) instead of connection._dbapi_connection.dbapi_connection.cursor() (attr doesnt exist)

https://github.com/databricks/databricks-sql-python/blame/0e7ce57ae4fecc364c4de55d6adace33c39aff5f/src/databricks/sqlalchemy/base.py#L360C13-L360C74

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions