Description
Version
1.40.0
Problem
We assume that engine.url
is always set in the SQLAlchemyIntegration
, but it's not always the case.
The customer is running Python 3.11 with Django 4.1.10, uWSGI 2.0.23 workers, SQLAlchemy 1.3.x.
Expected Result
No AttributeError
.
Actual Result
File "<redacted>/lib/python3.11/site-packages/gino/crud.py", line 537, in get
return await bind.first(clause)
^^^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/lib/python3.11/site-packages/gino/engine.py", line 748, in first
return await conn.first(clause, *multiparams, **params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/python3.11/site-packages/gino/engine.py", line 327, in first
result = self._execute(clause, multiparams, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/lib/python3.11/site-packages/gino/engine.py", line 295, in _execute
return self._sa_conn.execute(clause, *multiparams, **params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
return meth(self, multiparams, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1124, in _execute_clauseelement
ret = self._execute_context(
^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/lib/python3.11/site-packages/gino/engine.py", line 121, in _execute_context
return super()._execute_context(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "<redacted>/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1224, in _execute_context
statement, parameters = fn(
^^^
File "<redacted>/lib/python3.11/site-packages/sqlalchemy/events.py", line 636, in wrap_before_cursor_execute
orig_fn(
File "<redacted>/lib/python3.11/site-packages/sentry_sdk/integrations/sqlalchemy.py", line 70, in _before_cursor_execute
_set_db_data(span, conn)
File "<redacted>/lib/python3.11/site-packages/sentry_sdk/integrations/sqlalchemy.py", line 156, in _set_db_data
db_name = conn.engine.url.database
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'database'
Solution
Find out if there's another way to get the DB data we're currently getting via engine.url
. If so, do that. Otherwise, do not attach the DB data at all if engine.url
is None
.