MySQL server has gone away #241

Closed
opened 2024-05-03 09:22:10 +01:00 by kae · 1 comment
Owner
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
    1854  def _exec_single_context(
    1855      self,
    1856      dialect: Dialect,
    1857      context: ExecutionContext,
    1858      statement: Union[str, Compiled],
    1859      parameters: Optional[_AnyMultiExecuteParams],
    1860  ) -> CursorResult[Any]:
 (...)
    1967                      ):
    1968                          evt_handled = True
    1969                          break
    1970              if not evt_handled:
--> 1971                  self.dialect.do_execute(
    1972                      cursor, str_statement, effective_parameters, context
    ..................................................
     self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
                ct at 0x7f26be8a6a50>
     context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
                qldb object at 0x7f26200e5190>
     statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj
                  ect at 0x7f269bfa5f50>
     parameters = [(), ]
     evt_handled = False
     self.dialect.do_execute = <method 'DefaultDialect.do_execute' of <sqlalchemy.dialects.
                                mysql.mysqldb.MySQLDialect_mysqldb object at 0x7f26be8a6a50>
                                 default.py:918>
     cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     str_statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c
                      olour, notecolours.enabled, notecolours.is_regex, notecolour
                      s.is_casesensitive, notecolours.`order` \nFROM notecolours \
                      nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
                      er`'
     effective_parameters = ()
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
    918  def do_execute(self, cursor, statement, parameters, context=None):
--> 919      cursor.execute(statement, parameters)
    ..................................................
     self = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
             ct at 0x7f26be8a6a50>
     cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c
                  olour, notecolours.enabled, notecolours.is_regex, notecolour
                  s.is_casesensitive, notecolours.`order` \nFROM notecolours \
                  nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
                  er`'
     parameters = ()
     context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
                qldb object at 0x7f26200e5190>
     cursor.execute = <method 'BaseCursor.execute' of <MySQLdb.cursors.Cursor obje
                       ct at 0x7f26200e4290> cursors.py:162>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    162  def execute(self, query, args=None):
 (...)
    175  
    176      mogrified_query = self._mogrify(query, args)
    177  
    178      assert isinstance(mogrified_query, (bytes, bytearray))
--> 179      res = self._query(mogrified_query)
    180      return res
    ..................................................
     self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     query = 'SELECT notecolours.id, notecolours.substring, notecolours.c
              olour, notecolours.enabled, notecolours.is_regex, notecolour
              s.is_casesensitive, notecolours.`order` \nFROM notecolours \
              nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
              er`'
     args = ()
     mogrified_query = b'SELECT notecolours.id, notecolours.substring, notecolours.
                        colour, notecolours.enabled, notecolours.is_regex, notecolou
                        rs.is_casesensitive, notecolours.`order` \nFROM notecolours 
                        \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or
                        der`'
     self._mogrify = <method 'BaseCursor._mogrify' of <MySQLdb.cursors.Cursor obj
                      ect at 0x7f26200e4290> cursors.py:182>
     self._query = <method 'BaseCursor._query' of <MySQLdb.cursors.Cursor objec
                    t at 0x7f26200e4290> cursors.py:325>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    325  def _query(self, q):
    326      db = self._get_db()
    327      self._result = None
    328      self.rowcount = None
    329      self.lastrowid = None
--> 330      db.query(q)
    331      self._do_get_result(db)
    ..................................................
     self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     q = b'SELECT notecolours.id, notecolours.substring, notecolours.
          colour, notecolours.enabled, notecolours.is_regex, notecolou
          rs.is_casesensitive, notecolours.`order` \nFROM notecolours 
          \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or
          der`'
     db = <_mysql.connection closed at 0x3929360>
     self._get_db = <method 'BaseCursor._get_db' of <MySQLdb.cursors.Cursor obje
                     ct at 0x7f26200e4290> cursors.py:156>
     self._result = None
     self.rowcount = None
     self.lastrowid = None
     db.query = <method 'Connection.query' of <_mysql.connection closed at 0
                 x3929360> connections.py:257>
     self._do_get_result = <method 'BaseCursor._do_get_result' of <MySQLdb.cursors.Curs
                            or object at 0x7f26200e4290> cursors.py:135>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query
    257  def query(self, query):
    258      # Since _mysql releases GIL while querying, we need immutable buffer.
    259      if isinstance(query, bytearray):
    260          query = bytes(query)
--> 261      _mysql.connection.query(self, query)
    ..................................................
     query = b'SELECT notecolours.id, notecolours.substring, notecolours.
              colour, notecolours.enabled, notecolours.is_regex, notecolou
              rs.is_casesensitive, notecolours.`order` \nFROM notecolours 
              \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or
              der`'
     self = <_mysql.connection closed at 0x3929360>
    ..................................................

---- (full traceback above) ----
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
    self.dialect.do_execute(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
    cursor.execute(statement, parameters)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query
    _mysql.connection.query(self, query)

OperationalError: (2006, 'Server has gone away')

The above exception was the direct cause of the following exception:

File "/home/kae/mm/app/playlistmodel.py", line 360, in data
    339  def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole):
 (...)
    356          int(Qt.ItemDataRole.ToolTipRole): self.tooltip_role,
    357      }
    358  
    359      if role in dispatch_table:
--> 360          return dispatch_table[role](row, column, prd)
    361  
    ..................................................
     self = <PlaylistModel: playlist_id=142, 58 rows>
     index = <PyQt6.QtCore.QModelIndex object at 0x7f26a0295fc0>
     role = 8
     Qt.ItemDataRole.DisplayRole = <ItemDataRole.DisplayRole: 0>
     Qt.ItemDataRole.ToolTipRole = <ItemDataRole.ToolTipRole: 3>
     self.tooltip_role = <method 'PlaylistModel.tooltip_role' of <PlaylistModel: play
                          list_id=142, 58 rows> playlistmodel.py:1382>
     dispatch_table = {8: <method 'PlaylistModel.background_role' of <PlaylistMode
                       l: playlist_id=142, 58 rows> playlistmodel.py:191>,
                       0: <method 'PlaylistModel.display_role' of <PlaylistModel: 
                       playlist_id=142, 58 rows> playlistmodel.py:406>,
                       2: <method 'PlaylistModel.edit_role' of <PlaylistModel: pla
                       ylist_id=142, 58 rows> playlistmodel.py:473>,
                       6: <method 'PlaylistModel.font_role' of <PlaylistModel: pla
                       ylist_id=142, 58 rows> playlistmodel.py:510>,
                       3: <method 'PlaylistModel.tooltip_role' of <PlaylistModel: 
                       playlis...
     row = 19
     column = 1
     prd = <PlaylistRowData: plrid=567817, plr_rownum=19, note='Wrap-',
             title='', artist=''>
    ..................................................

File "/home/kae/mm/app/playlistmodel.py", line 199, in background_role
    191  def background_role(self, row: int, column: int, prd: PlaylistRowData) -> QBrush:
 (...)
    195      # Header row
    196      if self.is_header_row(row):
    197          # Check for specific header colouring
    198          with db.Session() as session:
--> 199              note_colour = NoteColours.get_colour(session, prd.note)
    200              if note_colour:
    ..................................................
     self = <PlaylistModel: playlist_id=142, 58 rows>
     row = 19
     column = 1
     prd = <PlaylistRowData: plrid=567817, plr_rownum=19, note='Wrap-',
             title='', artist=''>
     self.is_header_row = <method 'PlaylistModel.is_header_row' of <PlaylistModel: pla
                           ylist_id=142, 58 rows> playlistmodel.py:805>
     session = <sqlalchemy.orm.session.Session object at 0x7f26200e5810>
     prd.note = 'Wrap-'
    ..................................................

File "/home/kae/mm/app/models.py", line 100, in get_colour
    92   def get_colour(session: Session, text: str) -> Optional[str]:
 (...)
    96   
    97       if not text:
    98           return None
    99   
--> 100      for rec in session.scalars(
    101          select(NoteColours)
    ..................................................
     session = <sqlalchemy.orm.session.Session object at 0x7f26200e5810>
     text = 'Wrap-'
     session.scalars = <method 'Session.scalars' of <sqlalchemy.orm.session.Session
                         object at 0x7f26200e5810> session.py:2385>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2414, in scalars
    2385  def scalars(
    2386      self,
    2387      statement: Executable,
    2388      params: Optional[_CoreAnyExecuteParams] = None,
    2389      *,
    2390      execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT,
    2391      bind_arguments: Optional[_BindArguments] = None,
    2392      **kw: Any,
    2393  ) -> ScalarResult[Any]:
 (...)
    2410          of :meth:`_orm.Session.execute` to :meth:`_orm.Session.scalars`
    2411  
    2412      """
    2413  
--> 2414      return self._execute_internal(
    2415          statement,
    ..................................................
     self = <sqlalchemy.orm.session.Session object at 0x7f26200e5810>
     statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10>
     params = None
     execution_options = immutabledict
                         {}
     util.EMPTY_DICT = immutabledict
                       {}
     bind_arguments = None
     kw = {}
     self._execute_internal = <method 'Session._execute_internal' of <sqlalchemy.orm.sessi
                               on.Session object at 0x7f26200e5810> session.py:2078>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal
    2078  def _execute_internal(
    2079      self,
    2080      statement: Executable,
    2081      params: Optional[_CoreAnyExecuteParams] = None,
    2082      *,
    2083      execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT,
    2084      bind_arguments: Optional[_BindArguments] = None,
    2085      _parent_execute_state: Optional[Any] = None,
    2086      _add_event: Optional[Any] = None,
    2087      _scalar_result: bool = False,
    2088  ) -> Any:
 (...)
    2187              statement, params or {}, execution_options=execution_options
    2188          )
    2189  
    2190      if compile_state_cls:
--> 2191          result: Result[Any] = compile_state_cls.orm_execute_statement(
    2192              self,
    ..................................................
     self = <sqlalchemy.orm.session.Session object at 0x7f26200e5810>
     statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10>
     params = None
     execution_options = immutabledict
                         {'_result_disable_adapt_to...: True}
     util.EMPTY_DICT = immutabledict
                       {}
     bind_arguments = {'clause': <sqlalchemy.sql.selectable.Select object at 0x7f2
                       6200e4d10>,
                       'mapper': <Mapper at 0x7f26cb98bd50; NoteColours>}
     _parent_execute_state = None
     _add_event = None
     _scalar_result = False
     compile_state_cls.orm_execute_statement = <method 'AbstractORMCompileState.orm_execute_statement' of <
                                                class 'sqlalchemy.orm.context.ORMSelectCompileState'> contex
                                                t.py:283>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement
    284  def orm_execute_statement(
    285      cls,
    286      session,
    287      statement,
    288      params,
    289      execution_options,
    290      bind_arguments,
    291      conn,
    292  ) -> Result:
--> 293      result = conn.execute(
    294          statement, params or {}, execution_options=execution_options
    ..................................................
     session = <sqlalchemy.orm.session.Session object at 0x7f26200e5810>
     statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10>
     params = {}
     execution_options = immutabledict
                         {'_result_disable_adapt_to...: True}
     bind_arguments = {'clause': <sqlalchemy.sql.selectable.Select object at 0x7f2
                       6200e4d10>,
                       'mapper': <Mapper at 0x7f26cb98bd50; NoteColours>}
     conn = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     conn.execute = <method 'Connection.execute' of <sqlalchemy.engine.base.Conn
                     ection object at 0x7f26200e5450> base.py:1378>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1422, in execute
    1378  def execute(
    1379      self,
    1380      statement: Executable,
    1381      parameters: Optional[_CoreAnyExecuteParams] = None,
    1382      *,
    1383      execution_options: Optional[CoreExecuteOptionsParameter] = None,
    1384  ) -> CursorResult[Any]:
 (...)
    1418          meth = statement._execute_on_connection
    1419      except AttributeError as err:
    1420          raise exc.ObjectNotExecutableError(statement) from err
    1421      else:
--> 1422          return meth(
    1423              self,
    ..................................................
     self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10>
     parameters = {}
     execution_options = immutabledict
                         {'_result_disable_adapt_to...: True}
     meth = <method 'ClauseElement._execute_on_connection' of SELECT not
             ecolours.id, notecolours.substring, notecolours.colour, note
             colours.enabled, notecolours.is_regex, notecolours.is_casese
             nsitive, notecolours."order" 
            FROM notecolours 
            WHERE notecolours.enabled IS true ORDER BY notecolours."orde
             r" elements.py:505>
     statement._execute_on_connection = <method 'ClauseElement._execute_on_connection' of SELECT not
                                         ecolours.id, notecolours.substring, notecolours.colour, note
                                         colours.enabled, notecolours.is_regex, notecolours.is_casese
                                         nsitive, notecolours."order" 
                                        FROM notecolours 
                                        WHERE notecolours.enabled IS true ORDER BY notecolours."orde
                                         r" elements.py:505>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 514, in _execute_on_connection
    505  def _execute_on_connection(
    506      self,
    507      connection: Connection,
    508      distilled_params: _CoreMultiExecuteParams,
    509      execution_options: CoreExecuteOptionsParameter,
    510  ) -> Result[Any]:
    511      if self.supports_execution:
    512          if TYPE_CHECKING:
    513              assert isinstance(self, Executable)
--> 514          return connection._execute_clauseelement(
    515              self, distilled_params, execution_options
    ..................................................
     self = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10>
     connection = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     distilled_params = [{}, ]
     execution_options = immutabledict
                         {'_result_disable_adapt_to...: True}
     self.supports_execution = True
     TYPE_CHECKING = False
     connection._execute_clauseelement = <method 'Connection._execute_clauseelement' of <sqlalchemy.e
                                          ngine.base.Connection object at 0x7f26200e5450> base.py:1594
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1644, in _execute_clauseelement
    1594  def _execute_clauseelement(
    1595      self,
    1596      elem: Executable,
    1597      distilled_parameters: _CoreMultiExecuteParams,
    1598      execution_options: CoreExecuteOptionsParameter,
    1599  ) -> CursorResult[Any]:
 (...)
    1640          for_executemany=for_executemany,
    1641          schema_translate_map=schema_translate_map,
    1642          linting=self.dialect.compiler_linting | compiler.WARN_LINTING,
    1643      )
--> 1644      ret = self._execute_context(
    1645          dialect,
    ..................................................
     self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     elem = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10>
     distilled_parameters = [{}, ]
     execution_options = immutabledict
                         {'_result_disable_adapt_to...: True}
     for_executemany = False
     schema_translate_map = None
     self.dialect.compiler_linting = 1
     compiler.WARN_LINTING = <Linting.WARN_LINTING: 2>
     self._execute_context = <method 'Connection._execute_context' of <sqlalchemy.engine.
                              base.Connection object at 0x7f26200e5450> base.py:1795>
     dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
                ct at 0x7f26be8a6a50>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1850, in _execute_context
    1795  def _execute_context(
    1796      self,
    1797      dialect: Dialect,
    1798      constructor: Callable[..., ExecutionContext],
    1799      statement: Union[str, Compiled],
    1800      parameters: Optional[_AnyMultiExecuteParams],
    1801      execution_options: _ExecuteOptions,
    1802      *args: Any,
    1803      **kw: Any,
    1804  ) -> CursorResult[Any]:
 (...)
    1846  
    1847      if context.execute_style is ExecuteStyle.INSERTMANYVALUES:
    1848          return self._exec_insertmany_context(dialect, context)
    1849      else:
--> 1850          return self._exec_single_context(
    1851              dialect, context, statement, parameters
    ..................................................
     self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
                ct at 0x7f26be8a6a50>
     constructor = <method 'DefaultExecutionContext._init_compiled' of <class '
                    sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysq
                    ldb'> default.py:1271>
     statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj
                  ect at 0x7f269bfa5f50>
     parameters = [{}, ]
     execution_options = immutabledict
                         {'_result_disable_adapt_to...: True}
     args = (<sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb ob
             ject at 0x7f269bfa5f50>, [{...}, ], <sqlalchemy.sql.selectab
             le.Select object at 0x7f26200e4d10>, [], )
     kw = {'cache_hit': <CacheStats.CACHE_HIT: 0>}
     context.execute_style = <ExecuteStyle.EXECUTE: 0>
     ExecuteStyle.INSERTMANYVALUES = <ExecuteStyle.INSERTMANYVALUES: 2>
     self._exec_insertmany_context = <method 'Connection._exec_insertmany_context' of <sqlalchemy
                                      .engine.base.Connection object at 0x7f26200e5450> base.py:19
                                      96>
     context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
                qldb object at 0x7f26200e5190>
     self._exec_single_context = <method 'Connection._exec_single_context' of <sqlalchemy.eng
                                  ine.base.Connection object at 0x7f26200e5450> base.py:1854>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1990, in _exec_single_context
    1854  def _exec_single_context(
    1855      self,
    1856      dialect: Dialect,
    1857      context: ExecutionContext,
    1858      statement: Union[str, Compiled],
    1859      parameters: Optional[_AnyMultiExecuteParams],
    1860  ) -> CursorResult[Any]:
 (...)
    1986  
    1987          result = context._setup_result_proxy()
    1988  
    1989      except BaseException as e:
--> 1990          self._handle_dbapi_exception(
    1991              e, str_statement, effective_parameters, cursor, context
    ..................................................
     self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
                ct at 0x7f26be8a6a50>
     context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
                qldb object at 0x7f26200e5190>
     statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj
                  ect at 0x7f269bfa5f50>
     parameters = [(), ]
     context._setup_result_proxy = <method 'DefaultExecutionContext._setup_result_proxy' of <sq
                                    lalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqld
                                    b object at 0x7f26200e5190> default.py:1801>
     self._handle_dbapi_exception = <method 'Connection._handle_dbapi_exception' of <sqlalchemy.
                                     engine.base.Connection object at 0x7f26200e5450> base.py:222
                                     7>
     str_statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c
                      olour, notecolours.enabled, notecolours.is_regex, notecolour
                      s.is_casesensitive, notecolours.`order` \nFROM notecolours \
                      nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
                      er`'
     effective_parameters = ()
     cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2357, in _handle_dbapi_exception
    2227  def _handle_dbapi_exception(
    2228      self,
    2229      e: BaseException,
    2230      statement: Optional[str],
    2231      parameters: Optional[_AnyExecuteParams],
    2232      cursor: Optional[DBAPICursor],
    2233      context: Optional[ExecutionContext],
    2234      is_sub_exec: bool = False,
    2235  ) -> NoReturn:
 (...)
    2353          if newraise:
    2354              raise newraise.with_traceback(exc_info[2]) from e
    2355          elif should_wrap:
    2356              assert sqlalchemy_exception is not None
--> 2357              raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
    2358          else:
    ..................................................
     self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     e = OperationalError(2006, 'Server has gone away')
     statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c
                  olour, notecolours.enabled, notecolours.is_regex, notecolour
                  s.is_casesensitive, notecolours.`order` \nFROM notecolours \
                  nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
                  er`'
     parameters = ()
     cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
                qldb object at 0x7f26200e5190>
     is_sub_exec = False
     newraise = None
     newraise.with_traceback = # AttributeError
          newraise = None
     exc_info = (<class 'MySQLdb.OperationalError'>, OperationalError(2006, 
                 'Server has gone away'), <traceback object at 0x7f26200e4080
> , )
     should_wrap = True
     sqlalchemy_exception = OperationalError("(MySQLdb.OperationalError) (2006, 'Server 
                             has gone away')")
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
    1854  def _exec_single_context(
    1855      self,
    1856      dialect: Dialect,
    1857      context: ExecutionContext,
    1858      statement: Union[str, Compiled],
    1859      parameters: Optional[_AnyMultiExecuteParams],
    1860  ) -> CursorResult[Any]:
 (...)
    1967                      ):
    1968                          evt_handled = True
    1969                          break
    1970              if not evt_handled:
--> 1971                  self.dialect.do_execute(
    1972                      cursor, str_statement, effective_parameters, context
    ..................................................
     self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450>
     dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
                ct at 0x7f26be8a6a50>
     context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
                qldb object at 0x7f26200e5190>
     statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj
                  ect at 0x7f269bfa5f50>
     parameters = [(), ]
     evt_handled = False
     self.dialect.do_execute = <method 'DefaultDialect.do_execute' of <sqlalchemy.dialects.
                                mysql.mysqldb.MySQLDialect_mysqldb object at 0x7f26be8a6a50>
                                 default.py:918>
     cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     str_statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c
                      olour, notecolours.enabled, notecolours.is_regex, notecolour
                      s.is_casesensitive, notecolours.`order` \nFROM notecolours \
                      nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
                      er`'
     effective_parameters = ()
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
    918  def do_execute(self, cursor, statement, parameters, context=None):
--> 919      cursor.execute(statement, parameters)
    ..................................................
     self = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
             ct at 0x7f26be8a6a50>
     cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c
                  olour, notecolours.enabled, notecolours.is_regex, notecolour
                  s.is_casesensitive, notecolours.`order` \nFROM notecolours \
                  nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
                  er`'
     parameters = ()
     context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
                qldb object at 0x7f26200e5190>
     cursor.execute = <method 'BaseCursor.execute' of <MySQLdb.cursors.Cursor obje
                       ct at 0x7f26200e4290> cursors.py:162>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    162  def execute(self, query, args=None):
 (...)
    175  
    176      mogrified_query = self._mogrify(query, args)
    177  
    178      assert isinstance(mogrified_query, (bytes, bytearray))
--> 179      res = self._query(mogrified_query)
    180      return res
    ..................................................
     self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     query = 'SELECT notecolours.id, notecolours.substring, notecolours.c
              olour, notecolours.enabled, notecolours.is_regex, notecolour
              s.is_casesensitive, notecolours.`order` \nFROM notecolours \
              nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord
              er`'
     args = ()
     mogrified_query = b'SELECT notecolours.id, notecolours.substring, notecolours.
                        colour, notecolours.enabled, notecolours.is_regex, notecolou
                        rs.is_casesensitive, notecolours.`order` \nFROM notecolours 
                        \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or
                        der`'
     self._mogrify = <method 'BaseCursor._mogrify' of <MySQLdb.cursors.Cursor obj
                      ect at 0x7f26200e4290> cursors.py:182>
     self._query = <method 'BaseCursor._query' of <MySQLdb.cursors.Cursor objec
                    t at 0x7f26200e4290> cursors.py:325>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    325  def _query(self, q):
    326      db = self._get_db()
    327      self._result = None
    328      self.rowcount = None
    329      self.lastrowid = None
--> 330      db.query(q)
    331      self._do_get_result(db)
    ..................................................
     self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290>
     q = b'SELECT notecolours.id, notecolours.substring, notecolours.
          colour, notecolours.enabled, notecolours.is_regex, notecolou
          rs.is_casesensitive, notecolours.`order` \nFROM notecolours 
          \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or
          der`'
     db = <_mysql.connection closed at 0x3929360>
     self._get_db = <method 'BaseCursor._get_db' of <MySQLdb.cursors.Cursor obje
                     ct at 0x7f26200e4290> cursors.py:156>
     self._result = None
     self.rowcount = None
     self.lastrowid = None
     db.query = <method 'Connection.query' of <_mysql.connection closed at 0
                 x3929360> connections.py:257>
     self._do_get_result = <method 'BaseCursor._do_get_result' of <MySQLdb.cursors.Curs
                            or object at 0x7f26200e4290> cursors.py:135>
    ..................................................

File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query
    257  def query(self, query):
    258      # Since _mysql releases GIL while querying, we need immutable buffer.
    259      if isinstance(query, bytearray):
    260          query = bytes(query)
--> 261      _mysql.connection.query(self, query)
    ..................................................
     query = b'SELECT notecolours.id, notecolours.substring, notecolours.
              colour, notecolours.enabled, notecolours.is_regex, notecolou
              rs.is_casesensitive, notecolours.`order` \nFROM notecolours 
              \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or
              der`'
     self = <_mysql.connection closed at 0x3929360>
    ..................................................

---- (full traceback above) ----
File "/home/kae/mm/app/playlistmodel.py", line 360, in data
    return dispatch_table[role](row, column, prd)
File "/home/kae/mm/app/playlistmodel.py", line 199, in background_role
    note_colour = NoteColours.get_colour(session, prd.note)
File "/home/kae/mm/app/models.py", line 100, in get_colour
    for rec in session.scalars(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2414, in scalars
    return self._execute_internal(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal
    result: Result[Any] = compile_state_cls.orm_execute_statement(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement
    result = conn.execute(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1422, in execute
    return meth(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 514, in _execute_on_connection
    return connection._execute_clauseelement(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1644, in _execute_clauseelement
    ret = self._execute_context(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1850, in _execute_context
    return self._exec_single_context(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1990, in _exec_single_context
    self._handle_dbapi_exception(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2357, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context
    self.dialect.do_execute(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute
    cursor.execute(statement, parameters)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query
    _mysql.connection.query(self, query)

OperationalError: (MySQLdb.OperationalError) (2006, 'Server has gone away')
[SQL: SELECT notecolours.id, notecolours.substring, notecolours.colour, notecolours.enabled, notecolours.is_regex, notecolours.is_casesensitive, notecolours.`order` 
FROM notecolours 
WHERE notecolours.enabled IS true ORDER BY notecolours.`order`]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
``` File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context 1854 def _exec_single_context( 1855 self, 1856 dialect: Dialect, 1857 context: ExecutionContext, 1858 statement: Union[str, Compiled], 1859 parameters: Optional[_AnyMultiExecuteParams], 1860 ) -> CursorResult[Any]: (...) 1967 ): 1968 evt_handled = True 1969 break 1970 if not evt_handled: --> 1971 self.dialect.do_execute( 1972 cursor, str_statement, effective_parameters, context .................................................. self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje ct at 0x7f26be8a6a50> context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys qldb object at 0x7f26200e5190> statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj ect at 0x7f269bfa5f50> parameters = [(), ] evt_handled = False self.dialect.do_execute = <method 'DefaultDialect.do_execute' of <sqlalchemy.dialects. mysql.mysqldb.MySQLDialect_mysqldb object at 0x7f26be8a6a50> default.py:918> cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> str_statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' effective_parameters = () .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute 918 def do_execute(self, cursor, statement, parameters, context=None): --> 919 cursor.execute(statement, parameters) .................................................. self = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje ct at 0x7f26be8a6a50> cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' parameters = () context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys qldb object at 0x7f26200e5190> cursor.execute = <method 'BaseCursor.execute' of <MySQLdb.cursors.Cursor obje ct at 0x7f26200e4290> cursors.py:162> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute 162 def execute(self, query, args=None): (...) 175 176 mogrified_query = self._mogrify(query, args) 177 178 assert isinstance(mogrified_query, (bytes, bytearray)) --> 179 res = self._query(mogrified_query) 180 return res .................................................. self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> query = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' args = () mogrified_query = b'SELECT notecolours.id, notecolours.substring, notecolours. colour, notecolours.enabled, notecolours.is_regex, notecolou rs.is_casesensitive, notecolours.`order` \nFROM notecolours \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or der`' self._mogrify = <method 'BaseCursor._mogrify' of <MySQLdb.cursors.Cursor obj ect at 0x7f26200e4290> cursors.py:182> self._query = <method 'BaseCursor._query' of <MySQLdb.cursors.Cursor objec t at 0x7f26200e4290> cursors.py:325> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query 325 def _query(self, q): 326 db = self._get_db() 327 self._result = None 328 self.rowcount = None 329 self.lastrowid = None --> 330 db.query(q) 331 self._do_get_result(db) .................................................. self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> q = b'SELECT notecolours.id, notecolours.substring, notecolours. colour, notecolours.enabled, notecolours.is_regex, notecolou rs.is_casesensitive, notecolours.`order` \nFROM notecolours \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or der`' db = <_mysql.connection closed at 0x3929360> self._get_db = <method 'BaseCursor._get_db' of <MySQLdb.cursors.Cursor obje ct at 0x7f26200e4290> cursors.py:156> self._result = None self.rowcount = None self.lastrowid = None db.query = <method 'Connection.query' of <_mysql.connection closed at 0 x3929360> connections.py:257> self._do_get_result = <method 'BaseCursor._do_get_result' of <MySQLdb.cursors.Curs or object at 0x7f26200e4290> cursors.py:135> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query 257 def query(self, query): 258 # Since _mysql releases GIL while querying, we need immutable buffer. 259 if isinstance(query, bytearray): 260 query = bytes(query) --> 261 _mysql.connection.query(self, query) .................................................. query = b'SELECT notecolours.id, notecolours.substring, notecolours. colour, notecolours.enabled, notecolours.is_regex, notecolou rs.is_casesensitive, notecolours.`order` \nFROM notecolours \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or der`' self = <_mysql.connection closed at 0x3929360> .................................................. ---- (full traceback above) ---- File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context self.dialect.do_execute( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute cursor.execute(statement, parameters) File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query _mysql.connection.query(self, query) OperationalError: (2006, 'Server has gone away') The above exception was the direct cause of the following exception: File "/home/kae/mm/app/playlistmodel.py", line 360, in data 339 def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole): (...) 356 int(Qt.ItemDataRole.ToolTipRole): self.tooltip_role, 357 } 358 359 if role in dispatch_table: --> 360 return dispatch_table[role](row, column, prd) 361 .................................................. self = <PlaylistModel: playlist_id=142, 58 rows> index = <PyQt6.QtCore.QModelIndex object at 0x7f26a0295fc0> role = 8 Qt.ItemDataRole.DisplayRole = <ItemDataRole.DisplayRole: 0> Qt.ItemDataRole.ToolTipRole = <ItemDataRole.ToolTipRole: 3> self.tooltip_role = <method 'PlaylistModel.tooltip_role' of <PlaylistModel: play list_id=142, 58 rows> playlistmodel.py:1382> dispatch_table = {8: <method 'PlaylistModel.background_role' of <PlaylistMode l: playlist_id=142, 58 rows> playlistmodel.py:191>, 0: <method 'PlaylistModel.display_role' of <PlaylistModel: playlist_id=142, 58 rows> playlistmodel.py:406>, 2: <method 'PlaylistModel.edit_role' of <PlaylistModel: pla ylist_id=142, 58 rows> playlistmodel.py:473>, 6: <method 'PlaylistModel.font_role' of <PlaylistModel: pla ylist_id=142, 58 rows> playlistmodel.py:510>, 3: <method 'PlaylistModel.tooltip_role' of <PlaylistModel: playlis... row = 19 column = 1 prd = <PlaylistRowData: plrid=567817, plr_rownum=19, note='Wrap-', title='', artist=''> .................................................. File "/home/kae/mm/app/playlistmodel.py", line 199, in background_role 191 def background_role(self, row: int, column: int, prd: PlaylistRowData) -> QBrush: (...) 195 # Header row 196 if self.is_header_row(row): 197 # Check for specific header colouring 198 with db.Session() as session: --> 199 note_colour = NoteColours.get_colour(session, prd.note) 200 if note_colour: .................................................. self = <PlaylistModel: playlist_id=142, 58 rows> row = 19 column = 1 prd = <PlaylistRowData: plrid=567817, plr_rownum=19, note='Wrap-', title='', artist=''> self.is_header_row = <method 'PlaylistModel.is_header_row' of <PlaylistModel: pla ylist_id=142, 58 rows> playlistmodel.py:805> session = <sqlalchemy.orm.session.Session object at 0x7f26200e5810> prd.note = 'Wrap-' .................................................. File "/home/kae/mm/app/models.py", line 100, in get_colour 92 def get_colour(session: Session, text: str) -> Optional[str]: (...) 96 97 if not text: 98 return None 99 --> 100 for rec in session.scalars( 101 select(NoteColours) .................................................. session = <sqlalchemy.orm.session.Session object at 0x7f26200e5810> text = 'Wrap-' session.scalars = <method 'Session.scalars' of <sqlalchemy.orm.session.Session object at 0x7f26200e5810> session.py:2385> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2414, in scalars 2385 def scalars( 2386 self, 2387 statement: Executable, 2388 params: Optional[_CoreAnyExecuteParams] = None, 2389 *, 2390 execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, 2391 bind_arguments: Optional[_BindArguments] = None, 2392 **kw: Any, 2393 ) -> ScalarResult[Any]: (...) 2410 of :meth:`_orm.Session.execute` to :meth:`_orm.Session.scalars` 2411 2412 """ 2413 --> 2414 return self._execute_internal( 2415 statement, .................................................. self = <sqlalchemy.orm.session.Session object at 0x7f26200e5810> statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10> params = None execution_options = immutabledict {} util.EMPTY_DICT = immutabledict {} bind_arguments = None kw = {} self._execute_internal = <method 'Session._execute_internal' of <sqlalchemy.orm.sessi on.Session object at 0x7f26200e5810> session.py:2078> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal 2078 def _execute_internal( 2079 self, 2080 statement: Executable, 2081 params: Optional[_CoreAnyExecuteParams] = None, 2082 *, 2083 execution_options: OrmExecuteOptionsParameter = util.EMPTY_DICT, 2084 bind_arguments: Optional[_BindArguments] = None, 2085 _parent_execute_state: Optional[Any] = None, 2086 _add_event: Optional[Any] = None, 2087 _scalar_result: bool = False, 2088 ) -> Any: (...) 2187 statement, params or {}, execution_options=execution_options 2188 ) 2189 2190 if compile_state_cls: --> 2191 result: Result[Any] = compile_state_cls.orm_execute_statement( 2192 self, .................................................. self = <sqlalchemy.orm.session.Session object at 0x7f26200e5810> statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10> params = None execution_options = immutabledict {'_result_disable_adapt_to...: True} util.EMPTY_DICT = immutabledict {} bind_arguments = {'clause': <sqlalchemy.sql.selectable.Select object at 0x7f2 6200e4d10>, 'mapper': <Mapper at 0x7f26cb98bd50; NoteColours>} _parent_execute_state = None _add_event = None _scalar_result = False compile_state_cls.orm_execute_statement = <method 'AbstractORMCompileState.orm_execute_statement' of < class 'sqlalchemy.orm.context.ORMSelectCompileState'> contex t.py:283> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement 284 def orm_execute_statement( 285 cls, 286 session, 287 statement, 288 params, 289 execution_options, 290 bind_arguments, 291 conn, 292 ) -> Result: --> 293 result = conn.execute( 294 statement, params or {}, execution_options=execution_options .................................................. session = <sqlalchemy.orm.session.Session object at 0x7f26200e5810> statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10> params = {} execution_options = immutabledict {'_result_disable_adapt_to...: True} bind_arguments = {'clause': <sqlalchemy.sql.selectable.Select object at 0x7f2 6200e4d10>, 'mapper': <Mapper at 0x7f26cb98bd50; NoteColours>} conn = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> conn.execute = <method 'Connection.execute' of <sqlalchemy.engine.base.Conn ection object at 0x7f26200e5450> base.py:1378> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1422, in execute 1378 def execute( 1379 self, 1380 statement: Executable, 1381 parameters: Optional[_CoreAnyExecuteParams] = None, 1382 *, 1383 execution_options: Optional[CoreExecuteOptionsParameter] = None, 1384 ) -> CursorResult[Any]: (...) 1418 meth = statement._execute_on_connection 1419 except AttributeError as err: 1420 raise exc.ObjectNotExecutableError(statement) from err 1421 else: --> 1422 return meth( 1423 self, .................................................. self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> statement = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10> parameters = {} execution_options = immutabledict {'_result_disable_adapt_to...: True} meth = <method 'ClauseElement._execute_on_connection' of SELECT not ecolours.id, notecolours.substring, notecolours.colour, note colours.enabled, notecolours.is_regex, notecolours.is_casese nsitive, notecolours."order" FROM notecolours WHERE notecolours.enabled IS true ORDER BY notecolours."orde r" elements.py:505> statement._execute_on_connection = <method 'ClauseElement._execute_on_connection' of SELECT not ecolours.id, notecolours.substring, notecolours.colour, note colours.enabled, notecolours.is_regex, notecolours.is_casese nsitive, notecolours."order" FROM notecolours WHERE notecolours.enabled IS true ORDER BY notecolours."orde r" elements.py:505> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 514, in _execute_on_connection 505 def _execute_on_connection( 506 self, 507 connection: Connection, 508 distilled_params: _CoreMultiExecuteParams, 509 execution_options: CoreExecuteOptionsParameter, 510 ) -> Result[Any]: 511 if self.supports_execution: 512 if TYPE_CHECKING: 513 assert isinstance(self, Executable) --> 514 return connection._execute_clauseelement( 515 self, distilled_params, execution_options .................................................. self = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10> connection = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> distilled_params = [{}, ] execution_options = immutabledict {'_result_disable_adapt_to...: True} self.supports_execution = True TYPE_CHECKING = False connection._execute_clauseelement = <method 'Connection._execute_clauseelement' of <sqlalchemy.e ngine.base.Connection object at 0x7f26200e5450> base.py:1594 .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1644, in _execute_clauseelement 1594 def _execute_clauseelement( 1595 self, 1596 elem: Executable, 1597 distilled_parameters: _CoreMultiExecuteParams, 1598 execution_options: CoreExecuteOptionsParameter, 1599 ) -> CursorResult[Any]: (...) 1640 for_executemany=for_executemany, 1641 schema_translate_map=schema_translate_map, 1642 linting=self.dialect.compiler_linting | compiler.WARN_LINTING, 1643 ) --> 1644 ret = self._execute_context( 1645 dialect, .................................................. self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> elem = <sqlalchemy.sql.selectable.Select object at 0x7f26200e4d10> distilled_parameters = [{}, ] execution_options = immutabledict {'_result_disable_adapt_to...: True} for_executemany = False schema_translate_map = None self.dialect.compiler_linting = 1 compiler.WARN_LINTING = <Linting.WARN_LINTING: 2> self._execute_context = <method 'Connection._execute_context' of <sqlalchemy.engine. base.Connection object at 0x7f26200e5450> base.py:1795> dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje ct at 0x7f26be8a6a50> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1850, in _execute_context 1795 def _execute_context( 1796 self, 1797 dialect: Dialect, 1798 constructor: Callable[..., ExecutionContext], 1799 statement: Union[str, Compiled], 1800 parameters: Optional[_AnyMultiExecuteParams], 1801 execution_options: _ExecuteOptions, 1802 *args: Any, 1803 **kw: Any, 1804 ) -> CursorResult[Any]: (...) 1846 1847 if context.execute_style is ExecuteStyle.INSERTMANYVALUES: 1848 return self._exec_insertmany_context(dialect, context) 1849 else: --> 1850 return self._exec_single_context( 1851 dialect, context, statement, parameters .................................................. self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje ct at 0x7f26be8a6a50> constructor = <method 'DefaultExecutionContext._init_compiled' of <class ' sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysq ldb'> default.py:1271> statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj ect at 0x7f269bfa5f50> parameters = [{}, ] execution_options = immutabledict {'_result_disable_adapt_to...: True} args = (<sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb ob ject at 0x7f269bfa5f50>, [{...}, ], <sqlalchemy.sql.selectab le.Select object at 0x7f26200e4d10>, [], ) kw = {'cache_hit': <CacheStats.CACHE_HIT: 0>} context.execute_style = <ExecuteStyle.EXECUTE: 0> ExecuteStyle.INSERTMANYVALUES = <ExecuteStyle.INSERTMANYVALUES: 2> self._exec_insertmany_context = <method 'Connection._exec_insertmany_context' of <sqlalchemy .engine.base.Connection object at 0x7f26200e5450> base.py:19 96> context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys qldb object at 0x7f26200e5190> self._exec_single_context = <method 'Connection._exec_single_context' of <sqlalchemy.eng ine.base.Connection object at 0x7f26200e5450> base.py:1854> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1990, in _exec_single_context 1854 def _exec_single_context( 1855 self, 1856 dialect: Dialect, 1857 context: ExecutionContext, 1858 statement: Union[str, Compiled], 1859 parameters: Optional[_AnyMultiExecuteParams], 1860 ) -> CursorResult[Any]: (...) 1986 1987 result = context._setup_result_proxy() 1988 1989 except BaseException as e: --> 1990 self._handle_dbapi_exception( 1991 e, str_statement, effective_parameters, cursor, context .................................................. self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje ct at 0x7f26be8a6a50> context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys qldb object at 0x7f26200e5190> statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj ect at 0x7f269bfa5f50> parameters = [(), ] context._setup_result_proxy = <method 'DefaultExecutionContext._setup_result_proxy' of <sq lalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqld b object at 0x7f26200e5190> default.py:1801> self._handle_dbapi_exception = <method 'Connection._handle_dbapi_exception' of <sqlalchemy. engine.base.Connection object at 0x7f26200e5450> base.py:222 7> str_statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' effective_parameters = () cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2357, in _handle_dbapi_exception 2227 def _handle_dbapi_exception( 2228 self, 2229 e: BaseException, 2230 statement: Optional[str], 2231 parameters: Optional[_AnyExecuteParams], 2232 cursor: Optional[DBAPICursor], 2233 context: Optional[ExecutionContext], 2234 is_sub_exec: bool = False, 2235 ) -> NoReturn: (...) 2353 if newraise: 2354 raise newraise.with_traceback(exc_info[2]) from e 2355 elif should_wrap: 2356 assert sqlalchemy_exception is not None --> 2357 raise sqlalchemy_exception.with_traceback(exc_info[2]) from e 2358 else: .................................................. self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> e = OperationalError(2006, 'Server has gone away') statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' parameters = () cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys qldb object at 0x7f26200e5190> is_sub_exec = False newraise = None newraise.with_traceback = # AttributeError newraise = None exc_info = (<class 'MySQLdb.OperationalError'>, OperationalError(2006, 'Server has gone away'), <traceback object at 0x7f26200e4080 > , ) should_wrap = True sqlalchemy_exception = OperationalError("(MySQLdb.OperationalError) (2006, 'Server has gone away')") .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context 1854 def _exec_single_context( 1855 self, 1856 dialect: Dialect, 1857 context: ExecutionContext, 1858 statement: Union[str, Compiled], 1859 parameters: Optional[_AnyMultiExecuteParams], 1860 ) -> CursorResult[Any]: (...) 1967 ): 1968 evt_handled = True 1969 break 1970 if not evt_handled: --> 1971 self.dialect.do_execute( 1972 cursor, str_statement, effective_parameters, context .................................................. self = <sqlalchemy.engine.base.Connection object at 0x7f26200e5450> dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje ct at 0x7f26be8a6a50> context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys qldb object at 0x7f26200e5190> statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj ect at 0x7f269bfa5f50> parameters = [(), ] evt_handled = False self.dialect.do_execute = <method 'DefaultDialect.do_execute' of <sqlalchemy.dialects. mysql.mysqldb.MySQLDialect_mysqldb object at 0x7f26be8a6a50> default.py:918> cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> str_statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' effective_parameters = () .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute 918 def do_execute(self, cursor, statement, parameters, context=None): --> 919 cursor.execute(statement, parameters) .................................................. self = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje ct at 0x7f26be8a6a50> cursor = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> statement = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' parameters = () context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys qldb object at 0x7f26200e5190> cursor.execute = <method 'BaseCursor.execute' of <MySQLdb.cursors.Cursor obje ct at 0x7f26200e4290> cursors.py:162> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute 162 def execute(self, query, args=None): (...) 175 176 mogrified_query = self._mogrify(query, args) 177 178 assert isinstance(mogrified_query, (bytes, bytearray)) --> 179 res = self._query(mogrified_query) 180 return res .................................................. self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> query = 'SELECT notecolours.id, notecolours.substring, notecolours.c olour, notecolours.enabled, notecolours.is_regex, notecolour s.is_casesensitive, notecolours.`order` \nFROM notecolours \ nWHERE notecolours.enabled IS true ORDER BY notecolours.`ord er`' args = () mogrified_query = b'SELECT notecolours.id, notecolours.substring, notecolours. colour, notecolours.enabled, notecolours.is_regex, notecolou rs.is_casesensitive, notecolours.`order` \nFROM notecolours \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or der`' self._mogrify = <method 'BaseCursor._mogrify' of <MySQLdb.cursors.Cursor obj ect at 0x7f26200e4290> cursors.py:182> self._query = <method 'BaseCursor._query' of <MySQLdb.cursors.Cursor objec t at 0x7f26200e4290> cursors.py:325> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query 325 def _query(self, q): 326 db = self._get_db() 327 self._result = None 328 self.rowcount = None 329 self.lastrowid = None --> 330 db.query(q) 331 self._do_get_result(db) .................................................. self = <MySQLdb.cursors.Cursor object at 0x7f26200e4290> q = b'SELECT notecolours.id, notecolours.substring, notecolours. colour, notecolours.enabled, notecolours.is_regex, notecolou rs.is_casesensitive, notecolours.`order` \nFROM notecolours \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or der`' db = <_mysql.connection closed at 0x3929360> self._get_db = <method 'BaseCursor._get_db' of <MySQLdb.cursors.Cursor obje ct at 0x7f26200e4290> cursors.py:156> self._result = None self.rowcount = None self.lastrowid = None db.query = <method 'Connection.query' of <_mysql.connection closed at 0 x3929360> connections.py:257> self._do_get_result = <method 'BaseCursor._do_get_result' of <MySQLdb.cursors.Curs or object at 0x7f26200e4290> cursors.py:135> .................................................. File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query 257 def query(self, query): 258 # Since _mysql releases GIL while querying, we need immutable buffer. 259 if isinstance(query, bytearray): 260 query = bytes(query) --> 261 _mysql.connection.query(self, query) .................................................. query = b'SELECT notecolours.id, notecolours.substring, notecolours. colour, notecolours.enabled, notecolours.is_regex, notecolou rs.is_casesensitive, notecolours.`order` \nFROM notecolours \nWHERE notecolours.enabled IS true ORDER BY notecolours.`or der`' self = <_mysql.connection closed at 0x3929360> .................................................. ---- (full traceback above) ---- File "/home/kae/mm/app/playlistmodel.py", line 360, in data return dispatch_table[role](row, column, prd) File "/home/kae/mm/app/playlistmodel.py", line 199, in background_role note_colour = NoteColours.get_colour(session, prd.note) File "/home/kae/mm/app/models.py", line 100, in get_colour for rec in session.scalars( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2414, in scalars return self._execute_internal( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal result: Result[Any] = compile_state_cls.orm_execute_statement( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement result = conn.execute( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1422, in execute return meth( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 514, in _execute_on_connection return connection._execute_clauseelement( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1644, in _execute_clauseelement ret = self._execute_context( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1850, in _execute_context return self._exec_single_context( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1990, in _exec_single_context self._handle_dbapi_exception( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2357, in _handle_dbapi_exception raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context self.dialect.do_execute( File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute cursor.execute(statement, parameters) File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute res = self._query(mogrified_query) File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query db.query(q) File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/MySQLdb/connections.py", line 261, in query _mysql.connection.query(self, query) OperationalError: (MySQLdb.OperationalError) (2006, 'Server has gone away') [SQL: SELECT notecolours.id, notecolours.substring, notecolours.colour, notecolours.enabled, notecolours.is_regex, notecolours.is_casesensitive, notecolours.`order` FROM notecolours WHERE notecolours.enabled IS true ORDER BY notecolours.`order`] (Background on this error at: https://sqlalche.me/e/20/e3q8) ```
kae added the
bug
label 2024-05-03 09:22:10 +01:00
Author
Owner
See: - https://docs.sqlalchemy.org/en/20/faq/connections.html#mysql-server-has-gone-away - https://docs.sqlalchemy.org/en/20/core/pooling.html#pool-disconnects
kae closed this issue 2024-05-04 20:35:26 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kae/musicmuster#241
No description provided.