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

SQLAlchemy: Attempt to close session raised an exception at the server: Error during request to server #183

Open
freud14-tm opened this issue Aug 1, 2023 · 3 comments
Assignees
Labels
bug Something isn't working sqlalchemy

Comments

@freud14-tm
Copy link

freud14-tm commented Aug 1, 2023

When using the SQLAlchemy dialect, I get this error when my program closes after running that code:

import os

from sqlalchemy import create_engine


server_hostname = os.getenv("DATABRICKS_SERVER_HOSTNAME")
http_path = os.getenv("DATABRICKS_HTTP_PATH")
access_token = os.getenv("DATABRICKS_TOKEN")
engine = create_engine(
    f"databricks://token:{access_token}@{server_hostname}?http_path={http_path}&catalog=hive_metastore&schema=default",
)
with engine.connect() as connection:
    pass
Attempt to close session raised an exception at the server: Error during request to server

Here are version numbers:

In [1]: import sqlalchemy

In [2]: sqlalchemy.__version__
Out[2]: '1.4.49'

In [3]: from databricks import sql

In [4]: sql.__version__
Out[4]: '2.8.0'
@susodapop susodapop self-assigned this Aug 3, 2023
@rpanman-sonatype
Copy link

I notice the same when using databricks.sql.client directly via execute and fetchall on the cursor.

The appears to happen as the script exits (tested by inserting a sleep before exit - the error appears after the sleep has timed out).

$ poetry show | grep "databricks\|sql"
databricks-sql-connector 2.8.0      Databricks SQL Connector for Python
sqlalchemy               1.4.49     Database Abstraction Library

@rpanman-sonatype
Copy link

I've just tested with connector versions 2.7.0 (the error still occurs) and 2.6.0 (the error does not occur), so looks like something introduced in 2.7.0.

@sebbegg
Copy link
Contributor

sebbegg commented Aug 15, 2023

Looks like #157 imho

@kravets-levko kravets-levko added bug Something isn't working sqlalchemy labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sqlalchemy
Projects
None yet
Development

No branches or pull requests

5 participants