Duplicate entry for key 'tab' #239
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 0x7f0533065b90>
dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
ct at 0x7f05e24a1d10>
context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
qldb object at 0x7f05331aca50>
statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj
ect at 0x7f05331af050>
parameters = [(0, 8, ), ]
evt_handled = False
self.dialect.do_execute = <method 'DefaultDialect.do_execute' of <sqlalchemy.dialects.
mysql.mysqldb.MySQLDialect_mysqldb object at 0x7f05e24a1d10>
default.py:918>
cursor = <MySQLdb.cursors.Cursor object at 0x7f05331ac6d0>
str_statement = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
effective_parameters = (0, 8, )
..................................................
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 0x7f05e24a1d10>
cursor = <MySQLdb.cursors.Cursor object at 0x7f05331ac6d0>
statement = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
parameters = (0, 8, )
context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
qldb object at 0x7f05331aca50>
cursor.execute = <method 'BaseCursor.execute' of <MySQLdb.cursors.Cursor obje
ct at 0x7f05331ac6d0> 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 0x7f05331ac6d0>
query = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
args = (0, 8, )
mogrified_query = b'UPDATE playlists SET tab=0 WHERE playlists.id = 8'
self._mogrify = <method 'BaseCursor._mogrify' of <MySQLdb.cursors.Cursor obj
ect at 0x7f05331ac6d0> cursors.py:182>
self._query = <method 'BaseCursor._query' of <MySQLdb.cursors.Cursor objec
t at 0x7f05331ac6d0> 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 0x7f05331ac6d0>
q = b'UPDATE playlists SET tab=0 WHERE playlists.id = 8'
db = <_mysql.connection open to 'localhost' at 0x31c7960>
self._get_db = <method 'BaseCursor._get_db' of <MySQLdb.cursors.Cursor obje
ct at 0x7f05331ac6d0> cursors.py:156>
self._result = None
self.rowcount = None
self.lastrowid = None
db.query = <method 'Connection.query' of <_mysql.connection open to 'lo
calhost' at 0x31c7960> connections.py:257>
self._do_get_result = <method 'BaseCursor._do_get_result' of <MySQLdb.cursors.Curs
or object at 0x7f05331ac6d0> 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'UPDATE playlists SET tab=0 WHERE playlists.id = 8'
self = <_mysql.connection open to 'localhost' at 0x31c7960>
..................................................
---- (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)
IntegrityError: (1062, "Duplicate entry '0' for key 'tab'")
The above exception was the direct cause of the following exception:
File "/home/kae/mm/./app/musicmuster.py", line 467, in closeEvent
417 def closeEvent(self, event: Optional[QCloseEvent]) -> None:
(...)
463 playlist_id = self.tabPlaylist.widget(idx).playlist_id
464 playlist = session.get(Playlists, playlist_id)
465 if playlist:
466 playlist.tab = idx
--> 467 session.flush()
468
..................................................
self = <__main__.Window object at 0x7f05eeba9ab0>
event = <PyQt6.QtGui.QCloseEvent object at 0x7f05bc3e57e0>
playlist_id = 8
idx = 0
playlist = # error calling repr and str
session.get = <method 'Session.get' of <sqlalchemy.orm.session.Session obj
ect at 0x7f05bff1bbd0> session.py:3523>
playlist.tab = # DetachedInstanceError
playlist = # error calling repr and str
session.flush = <method 'Session.flush' of <sqlalchemy.orm.session.Session o
bject at 0x7f05bff1bbd0> session.py:4266>
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4296, in flush
4266 def flush(self, objects: Optional[Sequence[Any]] = None) -> None:
(...)
4292 if self._is_clean():
4293 return
4294 try:
4295 self._flushing = True
--> 4296 self._flush(objects)
4297 finally:
..................................................
self = <sqlalchemy.orm.session.Session object at 0x7f05bff1bbd0>
objects = None
self._is_clean = <method 'Session._is_clean' of <sqlalchemy.orm.session.Sessi
on object at 0x7f05bff1bbd0> session.py:4308>
self._flushing = False
self._flush = <method 'Session._flush' of <sqlalchemy.orm.session.Session
object at 0x7f05bff1bbd0> session.py:4315>
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4431, in _flush
4315 def _flush(self, objects: Optional[Sequence[object]] = None) -> None:
(...)
4427
4428 transaction.commit()
4429
4430 except:
--> 4431 with util.safe_reraise():
4432 transaction.rollback(_capture_exception=True)
..................................................
self = <sqlalchemy.orm.session.Session object at 0x7f05bff1bbd0>
objects = None
transaction.commit = <method 'SessionTransaction.commit' of <sqlalchemy.orm.sessi
on.SessionTransaction object at 0x7f05bc36dc20> <string>:1>
transaction.rollback = <method 'SessionTransaction.rollback' of <sqlalchemy.orm.ses
sion.SessionTransaction object at 0x7f05bc36dc20> <string>:1
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
134 def __exit__(
135 self,
136 type_: Optional[Type[BaseException]],
137 value: Optional[BaseException],
138 traceback: Optional[types.TracebackType],
139 ) -> NoReturn:
(...)
142 if type_ is None:
143 exc_type, exc_value, exc_tb = self._exc_info
144 assert exc_value is not None
145 self._exc_info = None # remove potential circular references
--> 146 raise exc_value.with_traceback(exc_tb)
147 else:
..................................................
self = <sqlalchemy.util.langhelpers.safe_reraise object at 0x7f05c7
1f2a70>
type_ = None
value = None
traceback = None
exc_value = IntegrityError('(MySQLdb.IntegrityError) (1062, "Duplicate e
ntry \'0\' for key \'tab\'")')
exc_tb = <traceback object at 0x7f05331ad640>
self._exc_info = None
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4392, in _flush
4315 def _flush(self, objects: Optional[Sequence[object]] = None) -> None:
(...)
4388 flush_context.transaction = transaction = self._autobegin_t()._begin()
4389 try:
4390 self._warn_on_events = True
4391 try:
--> 4392 flush_context.execute()
4393 finally:
..................................................
self = <sqlalchemy.orm.session.Session object at 0x7f05bff1bbd0>
objects = None
flush_context.transaction = <sqlalchemy.orm.session.SessionTransaction object at 0x7f05b
c36dc20>
transaction = <sqlalchemy.orm.session.SessionTransaction object at 0x7f05b
c36dc20>
self._autobegin_t = <method 'Session._autobegin_t' of <sqlalchemy.orm.session.Se
ssion object at 0x7f05bff1bbd0> session.py:1814>
self._warn_on_events = False
flush_context.execute = <method 'UOWTransaction.execute' of <sqlalchemy.orm.unitofwo
rk.UOWTransaction object at 0x7f05331d1a10> unitofwork.py:44
1>
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
441 def execute(self) -> None:
(...)
462 n = set_.pop()
463 n.execute_aggregate(self, set_)
464 else:
465 for rec in topological.sort(self.dependencies, postsort_actions):
--> 466 rec.execute(self)
..................................................
self = <sqlalchemy.orm.unitofwork.UOWTransaction object at 0x7f0533
1d1a10>
rec = SaveUpdateAll(Mapper[PlaylistsTable(playlists)])
topological.sort = <function 'sort' topological.py:58>
self.dependencies = {(SaveUpdateAll(Mapper[PlaylistsTable(playlists)]), DeleteAl
l(Mapper[PlaylistsTable(playlists)]), ), }
postsort_actions = [DeleteAll(Mapper[PlaylistsTable(playlists)]), SaveUpdateAll
(Mapper[PlaylistsTable(playlists)]), ]
rec.execute = <method 'SaveUpdateAll.execute' of SaveUpdateAll(Mapper[Play
listsTable(playlists)]) unitofwork.py:640>
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
640 @util.preload_module("sqlalchemy.orm.persistence")
641 def execute(self, uow):
--> 642 util.preloaded.orm_persistence.save_obj(
643 self.mapper,
..................................................
util.preload_module = <method '_ModuleRegistry.preload_module' of <sqlalchemy.util
.preloaded._ModuleRegistry object at 0x7f0619d87190> preload
ed.py:118>
self = SaveUpdateAll(Mapper[PlaylistsTable(playlists)])
uow = <sqlalchemy.orm.unitofwork.UOWTransaction object at 0x7f0533
1d1a10>
util.preloaded.orm_persistence.save_obj = <function 'save_obj' persistence.py:40>
self.mapper = <Mapper at 0x7f05ef5659d0; PlaylistsTable>
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 85, in save_obj
40 def save_obj(base_mapper, states, uowtransaction, single=False):
(...)
81 update = _collect_update_commands(
82 uowtransaction, table, states_to_update
83 )
84
--> 85 _emit_update_statements(
86 base_mapper,
..................................................
base_mapper = <Mapper at 0x7f05ef5659d0; PlaylistsTable>
states = <generator object UOWTransaction.states_for_mapper_hierarchy
at 0x7f05bff69140>
uowtransaction = <sqlalchemy.orm.unitofwork.UOWTransaction object at 0x7f0533
1d1a10>
single = False
update = <generator object _collect_update_commands at 0x7f05e25187c0
table = Table('playlists', MetaData(), Column('id', Integer(), table
=<playlists>, primary_key=True, nullable=False), Column('nam
e', String(length=32), table=<playlists>, nullable=False), C
olumn('last_used', DateTime(), table=<playlists>), Column('t
ab', Integer(), table=<playlists>), Column('open', Boolean()
, table=<playlists>, nullable=False, default=ScalarElementCo
lumnDefault(False)), Column('is_template', Boolean(), table=
<playlists>, nullable=False, default=ScalarElementColumnDefa
ult(False)), Column(...
states_to_update = [(<sqlalchemy.orm.state.InstanceState object at 0x7f05bc267b
f0>, {...}, <Mapper at 0x7f05ef59f910; Playlists>, <sqlalche
my.engine.base.Connection object at 0x7f0533065b90>, None, )
, ]
..................................................
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 912, in _emit_update_statements
728 def _emit_update_statements(
729 base_mapper,
730 uowtransaction,
731 mapper,
732 table,
733 update,
734 *,
735 bookkeeping=True,
736 use_orm_update_stmt=None,
737 enable_check_rowcount=True,
738 ):
(...)
908 assert_multirow
909 or (assert_singlerow and len(multiparams) == 1)
910 )
911
--> 912 c = connection.execute(
913 statement, multiparams, execution_options=execution_options
..................................................
base_mapper = <Mapper at 0x7f05ef5659d0; PlaylistsTable>
uowtransaction = <sqlalchemy.orm.unitofwork.UOWTransaction object at 0x7f0533
1d1a10>
mapper = <Mapper at 0x7f05ef5659d0; PlaylistsTable>
table = Table('playlists', MetaData(), Column('id', Integer(), table
=<playlists>, primary_key=True, nullable=False), Column('nam
e', String(length=32), table=<playlists>, nullable=False), C
olumn('last_used', DateTime(), table=<playlists>), Column('t
ab', Integer(), table=<playlists>), Column('open', Boolean()
, table=<playlists>, nullable=False, default=ScalarElementCo
lumnDefault(False)), Column('is_template', Boolean(), table=
<playlists>, nullable=False, default=ScalarElementColumnDefa
ult(False)), Column(...
update = <generator object _collect_update_commands at 0x7f05e25187c0
bookkeeping = True
use_orm_update_stmt = None
enable_check_rowcount = True
assert_multirow = True
assert_singlerow = True
multiparams = [
{'tab': 0,
'playlists_id': 8}, ]
connection.execute = <method 'Connection.execute' of <sqlalchemy.engine.base.Conn
ection object at 0x7f0533065b90> base.py:1378>
statement = <sqlalchemy.sql.dml.Update object at 0x7f05331acf10>
execution_options = {'compiled_cache': <sqlalchemy.util._collections.LRUCache ob
ject at 0x7f05bc30dd50>}
..................................................
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 0x7f0533065b90>
statement = <sqlalchemy.sql.dml.Update object at 0x7f05331acf10>
parameters = [
{'tab': 0,
'playlists_id': 8}, ]
execution_options = {'compiled_cache': <sqlalchemy.util._collections.LRUCache ob
ject at 0x7f05bc30dd50>}
meth = <method 'ClauseElement._execute_on_connection' of UPDATE pla
ylists SET id=:id, name=:name, last_used=:last_used, tab=:ta
b, open=:open, is_template=:is_template, deleted=:deleted WH
ERE playlists.id = :playlists_id elements.py:505>
statement._execute_on_connection = <method 'ClauseElement._execute_on_connection' of UPDATE pla
ylists SET id=:id, name=:name, last_used=:last_used, tab=:ta
b, open=:open, is_template=:is_template, deleted=:deleted WH
ERE playlists.id = :playlists_id 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.dml.Update object at 0x7f05331acf10>
connection = <sqlalchemy.engine.base.Connection object at 0x7f0533065b90>
distilled_params = [
{'tab': 0,
'playlists_id': 8}, ]
execution_options = {'compiled_cache': <sqlalchemy.util._collections.LRUCache ob
ject at 0x7f05bc30dd50>}
self.supports_execution = True
TYPE_CHECKING = False
connection._execute_clauseelement = <method 'Connection._execute_clauseelement' of <sqlalchemy.e
ngine.base.Connection object at 0x7f0533065b90> 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 0x7f0533065b90>
elem = <sqlalchemy.sql.dml.Update object at 0x7f05331acf10>
distilled_parameters = [
{'tab': 0,
'playlists_id': 8}, ]
execution_options = immutabledict
{'compiled_cache': <sqlalchemy.util._collections.LRUCache ob
ject at 0x7f05bc30dd50>}
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 0x7f0533065b90> base.py:1795>
dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
ct at 0x7f05e24a1d10>
..................................................
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 0x7f0533065b90>
dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
ct at 0x7f05e24a1d10>
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 0x7f05331af050>
parameters = [
{'tab': 0,
'playlists_id': 8}, ]
execution_options = immutabledict
{'compiled_cache': <sqlalchemy.util._collections.LRUCache ob
ject at 0x7f05bc30dd50>}
args = (<sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb ob
ject at 0x7f05331af050>, [{...}, ], <sqlalchemy.sql.dml.Upda
te object at 0x7f05331acf10>, [BindParameter('playlists_id',
None, type_=Integer()), ], )
kw = {'cache_hit': <CacheStats.CACHE_MISS: 1>}
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 0x7f0533065b90> base.py:19
96>
context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
qldb object at 0x7f05331aca50>
self._exec_single_context = <method 'Connection._exec_single_context' of <sqlalchemy.eng
ine.base.Connection object at 0x7f0533065b90> 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 0x7f0533065b90>
dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
ct at 0x7f05e24a1d10>
context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
qldb object at 0x7f05331aca50>
statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj
ect at 0x7f05331af050>
parameters = [(0, 8, ), ]
context._setup_result_proxy = <method 'DefaultExecutionContext._setup_result_proxy' of <sq
lalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqld
b object at 0x7f05331aca50> default.py:1801>
self._handle_dbapi_exception = <method 'Connection._handle_dbapi_exception' of <sqlalchemy.
engine.base.Connection object at 0x7f0533065b90> base.py:222
7>
str_statement = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
effective_parameters = (0, 8, )
cursor = <MySQLdb.cursors.Cursor object at 0x7f05331ac6d0>
..................................................
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 0x7f0533065b90>
e = IntegrityError(1062, "Duplicate entry '0' for key 'tab'")
statement = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
parameters = (0, 8, )
cursor = <MySQLdb.cursors.Cursor object at 0x7f05331ac6d0>
context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
qldb object at 0x7f05331aca50>
is_sub_exec = False
newraise = None
newraise.with_traceback = # AttributeError
newraise = None
exc_info = (<class 'MySQLdb.IntegrityError'>, IntegrityError(1062, "Dup
licate entry '0' for key 'tab'"), <traceback object at 0x7f0
5331afe00>, )
should_wrap = True
sqlalchemy_exception = IntegrityError('(MySQLdb.IntegrityError) (1062, "Duplicate e
ntry \'0\' for key \'tab\'")')
..................................................
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 0x7f0533065b90>
dialect = <sqlalchemy.dialects.mysql.mysqldb.MySQLDialect_mysqldb obje
ct at 0x7f05e24a1d10>
context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
qldb object at 0x7f05331aca50>
statement = <sqlalchemy.dialects.mysql.mysqldb.MySQLCompiler_mysqldb obj
ect at 0x7f05331af050>
parameters = [(0, 8, ), ]
evt_handled = False
self.dialect.do_execute = <method 'DefaultDialect.do_execute' of <sqlalchemy.dialects.
mysql.mysqldb.MySQLDialect_mysqldb object at 0x7f05e24a1d10>
default.py:918>
cursor = <MySQLdb.cursors.Cursor object at 0x7f05331ac6d0>
str_statement = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
effective_parameters = (0, 8, )
..................................................
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 0x7f05e24a1d10>
cursor = <MySQLdb.cursors.Cursor object at 0x7f05331ac6d0>
statement = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
parameters = (0, 8, )
context = <sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mys
qldb object at 0x7f05331aca50>
cursor.execute = <method 'BaseCursor.execute' of <MySQLdb.cursors.Cursor obje
ct at 0x7f05331ac6d0> 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 0x7f05331ac6d0>
query = 'UPDATE playlists SET tab=%s WHERE playlists.id = %s'
args = (0, 8, )
mogrified_query = b'UPDATE playlists SET tab=0 WHERE playlists.id = 8'
self._mogrify = <method 'BaseCursor._mogrify' of <MySQLdb.cursors.Cursor obj
ect at 0x7f05331ac6d0> cursors.py:182>
self._query = <method 'BaseCursor._query' of <MySQLdb.cursors.Cursor objec
t at 0x7f05331ac6d0> 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 0x7f05331ac6d0>
q = b'UPDATE playlists SET tab=0 WHERE playlists.id = 8'
db = <_mysql.connection open to 'localhost' at 0x31c7960>
self._get_db = <method 'BaseCursor._get_db' of <MySQLdb.cursors.Cursor obje
ct at 0x7f05331ac6d0> cursors.py:156>
self._result = None
self.rowcount = None
self.lastrowid = None
db.query = <method 'Connection.query' of <_mysql.connection open to 'lo
calhost' at 0x31c7960> connections.py:257>
self._do_get_result = <method 'BaseCursor._do_get_result' of <MySQLdb.cursors.Curs
or object at 0x7f05331ac6d0> 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'UPDATE playlists SET tab=0 WHERE playlists.id = 8'
self = <_mysql.connection open to 'localhost' at 0x31c7960>
..................................................
---- (full traceback above) ----
File "/home/kae/mm/./app/musicmuster.py", line 467, in closeEvent
session.flush()
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4296, in flush
self._flush(objects)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4431, in _flush
with util.safe_reraise():
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
raise exc_value.with_traceback(exc_tb)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 4392, in _flush
flush_context.execute()
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
rec.execute(self)
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
util.preloaded.orm_persistence.save_obj(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 85, in save_obj
_emit_update_statements(
File "/home/kae/.cache/pypoetry/virtualenvs/musicmuster-21R3m3EB-py3.11/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 912, in _emit_update_statements
c = connection.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)
IntegrityError: (MySQLdb.IntegrityError) (1062, "Duplicate entry '0' for key 'tab'")
[SQL: UPDATE playlists SET tab=%s WHERE playlists.id = %s]
[parameters: (0, 8)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
```
bug
label
Save open tabs properly
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?