Skip to content

Dialect: Add methods concerned with isolation levels as no-ops #217

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amotl
Copy link
Member

@amotl amotl commented Apr 2, 2025

About

This was needed for unlocking mcp-alchemy, because it called set_isolation_level() on the dialect instance.

References

Backlog

  • Software tests.
  • Documentation.

Comment on lines +209 to +216
def get_isolation_level_values(self, dbapi_conn):
return ()

def set_isolation_level(self, dbapi_connection, level):
pass

def get_isolation_level(self, dbapi_connection):
return "NONE"
Copy link
Member Author

@amotl amotl Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any recommendations?

Copy link
Member Author

@amotl amotl Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consulting Wikipedia and the SQLAlchemy documentation, READ UNCOMMITTED might be the right choice for CrateDB?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typical PostgreSQL drivers in Java (JDBC) and Python offer the same quartet, and Apache Spark additionally seems to provide NONE.

So, I guess using READ UNCOMMITTED as the default and single valid choice for CrateDB is the right way to resolve the situation?

Copy link
Member Author

@amotl amotl Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like specifically for SQLAlchemy, AUTOCOMMIT seems to be more appropriate.

SQLAlchemy treats the concept of “autocommit” like any other isolation level; in that it is an isolation level that loses not only “read committed” but also loses atomicity. [...] This usually means that the typical DBAPI behavior of emitting BEGIN to the database automatically no longer occurs.

-- https://docs.sqlalchemy.org/en/20/core/connections.html#dbapi-autocommit

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.

1 participant