Anlegen wiederkehrende Kosten duplicate key #8
jlusiardi
commented 2024-05-22 08:46:47 +02:00
Owner
```
May 22 06:41:14 www gunicorn[12393]: mapper = orm.class_mapper(type)
May 22 06:44:08 www gunicorn[12392]: ERROR:app:Exception on /regular_costs/vehicle/31/create [POST]
May 22 06:44:08 www gunicorn[12392]: Traceback (most recent call last):
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
May 22 06:44:08 www gunicorn[12392]: self.dialect.do_execute(
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
May 22 06:44:08 www gunicorn[12392]: cursor.execute(statement, parameters)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/cursors.py", line 148, in execute
May 22 06:44:08 www gunicorn[12392]: result = self._query(query)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/cursors.py", line 310, in _query
May 22 06:44:08 www gunicorn[12392]: conn.query(q)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 548, in query
May 22 06:44:08 www gunicorn[12392]: self._affected_rows = self._read_query_result(unbuffered=unbuffered)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 775, in _read_query_result
May 22 06:44:08 www gunicorn[12392]: result.read()
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 1156, in read
May 22 06:44:08 www gunicorn[12392]: first_packet = self.connection._read_packet()
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 725, in _read_packet
May 22 06:44:08 www gunicorn[12392]: packet.raise_for_error()
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
May 22 06:44:08 www gunicorn[12392]: err.raise_mysql_exception(self._data)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
May 22 06:44:08 www gunicorn[12392]: raise errorclass(errno, errval)
May 22 06:44:08 www gunicorn[12392]: pymysql.err.IntegrityError: (1062, "Duplicate entry 'Steuer' for key 'description'")
May 22 06:44:08 www gunicorn[12392]: The above exception was the direct cause of the following exception:
May 22 06:44:08 www gunicorn[12392]: Traceback (most recent call last):
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/flask/app.py", line 2077, in wsgi_app
May 22 06:44:08 www gunicorn[12392]: response = self.full_dispatch_request()
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/flask/app.py", line 1525, in full_dispatch_request
May 22 06:44:08 www gunicorn[12392]: rv = self.handle_user_exception(e)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/flask/app.py", line 1523, in full_dispatch_request
May 22 06:44:08 www gunicorn[12392]: rv = self.dispatch_request()
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/flask/app.py", line 1509, in dispatch_request
May 22 06:44:08 www gunicorn[12392]: return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/flask_login/utils.py", line 290, in decorated_view
May 22 06:44:08 www gunicorn[12392]: return current_app.ensure_sync(func)(*args, **kwargs)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/pitstops/app/routes/regular_cost.py", line 89, in create_regular_cost_for_vehicle
May 22 06:44:08 www gunicorn[12392]: vehicle.regulars.append(regular_cost)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/attributes.py", line 481, in __get__
May 22 06:44:08 www gunicorn[12392]: return self.impl.get(state, dict_)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/attributes.py", line 941, in get
May 22 06:44:08 www gunicorn[12392]: value = self._fire_loader_callables(state, key, passive)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/attributes.py", line 977, in _fire_loader_callables
May 22 06:44:08 www gunicorn[12392]: return self.callable_(state, passive)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/strategies.py", line 911, in _load_for_state
May 22 06:44:08 www gunicorn[12392]: return self._emit_lazyload(
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/strategies.py", line 1047, in _emit_lazyload
May 22 06:44:08 www gunicorn[12392]: result = session.execute(
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 1644, in execute
May 22 06:44:08 www gunicorn[12392]: ) = compile_state_cls.orm_pre_session_exec(
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 319, in orm_pre_session_exec
May 22 06:44:08 www gunicorn[12392]: session._autoflush()
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2241, in _autoflush
May 22 06:44:08 www gunicorn[12392]: util.raise_(e, with_traceback=sys.exc_info()[2])
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
May 22 06:44:08 www gunicorn[12392]: raise exception
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2230, in _autoflush
May 22 06:44:08 www gunicorn[12392]: self.flush()
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 3367, in flush
May 22 06:44:08 www gunicorn[12392]: self._flush(objects)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 3506, in _flush
May 22 06:44:08 www gunicorn[12392]: with util.safe_reraise():
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
May 22 06:44:08 www gunicorn[12392]: compat.raise_(
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
May 22 06:44:08 www gunicorn[12392]: raise exception
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 3467, in _flush
May 22 06:44:08 www gunicorn[12392]: flush_context.execute()
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
May 22 06:44:08 www gunicorn[12392]: rec.execute(self)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
May 22 06:44:08 www gunicorn[12392]: util.preloaded.orm_persistence.save_obj(
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
May 22 06:44:08 www gunicorn[12392]: _emit_insert_statements(
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/orm/persistence.py", line 1238, in _emit_insert_statements
May 22 06:44:08 www gunicorn[12392]: result = connection._execute_20(
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1631, in _execute_20
May 22 06:44:08 www gunicorn[12392]: return meth(self, args_10style, kwargs_10style, execution_options)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
May 22 06:44:08 www gunicorn[12392]: return connection._execute_clauseelement(
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
May 22 06:44:08 www gunicorn[12392]: ret = self._execute_context(
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
May 22 06:44:08 www gunicorn[12392]: self._handle_dbapi_exception(
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception
May 22 06:44:08 www gunicorn[12392]: util.raise_(
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
May 22 06:44:08 www gunicorn[12392]: raise exception
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
May 22 06:44:08 www gunicorn[12392]: self.dialect.do_execute(
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
May 22 06:44:08 www gunicorn[12392]: cursor.execute(statement, parameters)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/cursors.py", line 148, in execute
May 22 06:44:08 www gunicorn[12392]: result = self._query(query)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/cursors.py", line 310, in _query
May 22 06:44:08 www gunicorn[12392]: conn.query(q)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 548, in query
May 22 06:44:08 www gunicorn[12392]: self._affected_rows = self._read_query_result(unbuffered=unbuffered)
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 775, in _read_query_result
May 22 06:44:08 www gunicorn[12392]: result.read()
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 1156, in read
May 22 06:44:08 www gunicorn[12392]: first_packet = self.connection._read_packet()
May 22 06:44:08 www gunicorn[12392]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/connections.py", line 725, in _read_packet
May 22 06:44:08 www gunicorn[12392]: packet.raise_for_error()
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
May 22 06:44:08 www gunicorn[12392]: err.raise_mysql_exception(self._data)
May 22 06:44:08 www gunicorn[12392]: File "/var/www/.pitstops_env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
May 22 06:44:08 www gunicorn[12392]: raise errorclass(errno, errval)
May 22 06:44:08 www gunicorn[12392]: sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
May 22 06:44:08 www gunicorn[12392]: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'Steuer' for key 'description'")
May 22 06:44:08 www gunicorn[12392]: [SQL: INSERT INTO regular_cost (vehicle_id, description, costs, days, start_at, ends_at) VALUES (%(vehicle_id)s, %(description)s, %(costs)s, %(days)s, %(start_at)s, %(ends_at)s)]
May 22 06:44:08 www gunicorn[12392]: [parameters: {'vehicle_id': 31, 'description': 'Steuer', 'costs': Decimal('40'), 'days': '05-21', 'start_at': datetime.date(2024, 5, 22), 'ends_at': None}]
May 22 06:44:08 www gunicorn[12392]: (Background on this error at: https://sqlalche.me/e/14/gkpj)
```
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?