Skip to content

Conversation

@caiohamamura
Copy link

Whenever the sqlachemy tries to use set_isolation_level without it being defined it will cast object has no attribute 'set_isolation_level' instead of gracefully handling the error by explicitly raising NotImplementedError

@caiohamamura caiohamamura changed the title Handle set_isolation_level gracefully fix: handle set_isolation_level gracefully Apr 15, 2025
@Mause
Copy link
Owner

Mause commented Sep 28, 2025

hey there, thanks for submitting this PR! any chance we could see a test demonstrating the issue and proving that it's fixed?

@caiohamamura
Copy link
Author

caiohamamura commented Sep 29, 2025

You can check this by using:

from sqlalchemy import create_engine

eng = create_engine("duckdb:///:memory:")
conn = eng.connect()
try:
    eng.dialect.set_isolation_level(conn, '1')
except NotImplementedError:
    print('Expected not implemented error raised!')
except Exception as e:
    raise(e)

This will allow other libraries using duckdb-engine to more gracefully handle expected errors, since engine PGDialect implements set_isolation_level, but duckdb does not.

Whenever the sqlachemy tries to use set_isolation_level without it being defined it will cast `object has no attribute 'set_isolation_level'` instead of gracefully handling the error by explicitly raising it is not implemented.
@caiohamamura
Copy link
Author

I rebased against main for merging!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants