Skip to content

Exception Raised On Connect in 1.11.0 #659

Open
@waltaskew

Description

@waltaskew

Environment details

  • Programming language: python
  • OS: linux
  • Language runtime version: 3.12.2
  • Package version: 1.11.0
  • google-cloud-spanner version: 3.42.0

Steps to reproduce

engine = sqlalchemy.create_engine(
    "spanner+spanner:///..."
)

with engine.begin() as conn:

throws an exception. It looks like the issue is that the dialect now depends upon a newer version of google-cloud-spanner / the dbapi. This fixed the issue:

pip install --upgrade google-cloud-spanner

which took me from google-cloud-spanner-3.42.0 to google-cloud-spanner-3.54.0

So the required version appears to be somewhere between those two. Looks like the setup.py needs to be updated to state the new required version.

Traceback (most recent call last):
  File "/p.py", line 7, in <module>
    with engine.begin() as conn:
  File "/opt/python3.12.2/lib/python3.12/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3238, in begin
    with self.connect() as conn:
         ^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3274, in connect
    return self._connection_cls(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 3298, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 449, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1264, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 713, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
    with util.safe_reraise():
  File "lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "lib/python3.12/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 675, in __init__
    self.__connect()
  File "lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 915, in __connect
    )._exec_w_sync_on_first_run(self.dbapi_connection, self)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/event/attr.py", line 483, in _exec_w_sync_on_first_run
    self(*args, **kw)
  File "lib/python3.12/site-packages/sqlalchemy/event/attr.py", line 497, in __call__
    fn(*args, **kw)
  File "lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 1916, in go
    return once_fn(*arg, **kw)
           ^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/engine/create.py", line 752, in first_connect
    dialect.initialize(c)
  File "lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 536, in initialize
    self.default_isolation_level = self.get_default_isolation_level(
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 587, in get_default_isolation_level
    return self.get_isolation_level(dbapi_conn)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.12/site-packages/google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py", line 1734, in get_isolation_level
    level = conn.isolation_level
            ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Connection' object has no attribute 'isolation_level'

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/python-spanner-sqlalchemy API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions