|
1
|
Message: <!doctype html> <html lang=en> <head> <title>sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) BŁĄD: wstawianie lub modyfikacja na tabeli "oil_analysis_harmonogram" narusza klucz obcy "FK_device_id" DETAIL: Klucz (device_id_fkey)=(69436) nie występuje w tabeli "devices". [SQL: INSERT INTO cbm.oil_analysis_harmonogram (oil_analysis_harmonogram_id_pkey, ship_id_fkey, device_id_fkey, report_number, report_type_id_fkey) VALUES (%(oil_analysis_harmonogram_id_pkey)s, %(ship_id_fkey)s, %(device_id_fkey)s, %(report_number)s, %(report_type_id_fkey)s)] [parameters: {'oil_analysis_harmonogram_id_pkey': 688, 'ship_id_fkey': 344, 'device_id_fkey': '69436', 'report_number': '18241482127', 'report_type_id_fkey': '292'}] (Background on this error at: https://sqlalche.me/e/14/gkpj) // Werkzeug Debugger</title> <link rel="stylesheet" href="?__debugger__=yes&cmd=resource&f=style.css"> <link rel="shortcut icon" href="?__debugger__=yes&cmd=resource&f=console.png"> <script src="?__debugger__=yes&cmd=resource&f=debugger.js"></script> <script> var CONSOLE_MODE = false, EVALEX = true, EVALEX_TRUSTED = false, SECRET = "ZwX7Qo8aoQRu3rRVX4BI"; </script> </head> <body style="background-color: #fff"> <div class="debugger"> <h1>IntegrityError</h1> <div class="detail"> <p class="errormsg">sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) BŁĄD: wstawianie lub modyfikacja na tabeli "oil_analysis_harmonogram" narusza klucz obcy "FK_device_id" DETAIL: Klucz (device_id_fkey)=(69436) nie występuje w tabeli "devices". [SQL: INSERT INTO cbm.oil_analysis_harmonogram (oil_analysis_harmonogram_id_pkey, ship_id_fkey, device_id_fkey, report_number, report_type_id_fkey) VALUES (%(oil_analysis_harmonogram_id_pkey)s, %(ship_id_fkey)s, %(device_id_fkey)s, %(report_number)s, %(report_type_id_fkey)s)] [parameters: {'oil_analysis_harmonogram_id_pkey': 688, 'ship_id_fkey': 344, 'device_id_fkey': '69436', 'report_number': '18241482127', 'report_type_id_fkey': '292'}] (Background on this error at: https://sqlalche.me/e/14/gkpj) </p> </div> <h2 class="traceback">Traceback <em>(most recent call last)</em></h2> <div class="traceback"> <h3></h3> <ul><li><div class="frame" id="frame-140703257563216"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1901</em>, in <code class="function">_execute_context</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>if fn(cursor, statement, parameters, context):</pre> <pre class="line before"><span class="ws"> </span>evt_handled = True</pre> <pre class="line before"><span class="ws"> </span>break</pre> <pre class="line before"><span class="ws"> </span>if not evt_handled:</pre> <pre class="line before"><span class="ws"> </span>self.dialect.do_execute(</pre> <pre class="line current"><span class="ws"> </span>cursor, statement, parameters, context</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if self._has_events or self.engine._has_events:</pre> <pre class="line after"><span class="ws"> </span>self.dispatch.after_cursor_execute(</pre> <pre class="line after"><span class="ws"> </span>self,</pre></div> </div> <li><div class="frame" id="frame-140703257563344"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py"</cite>, line <em class="line">736</em>, in <code class="function">do_execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def do_executemany(self, cursor, statement, parameters, context=None):</pre> <pre class="line before"><span class="ws"> </span>cursor.executemany(statement, parameters)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def do_execute(self, cursor, statement, parameters, context=None):</pre> <pre class="line current"><span class="ws"> </span>cursor.execute(statement, parameters)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def do_execute_no_params(self, cursor, statement, context=None):</pre> <pre class="line after"><span class="ws"> </span>cursor.execute(statement)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def is_disconnect(self, e, connection, cursor):</pre></div> </div> <li><div class="exc-divider">The above exception was the direct cause of the following exception:</div> <li><div class="frame" id="frame-140703257812432"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>, line <em class="line">2095</em>, in <code class="function">__call__</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>def __call__(self, environ: dict, start_response: t.Callable) -> t.Any:</pre> <pre class="line before"><span class="ws"> </span>"""The WSGI server calls the Flask application object as the</pre> <pre class="line before"><span class="ws"> </span>WSGI application. This calls :meth:`wsgi_app`, which can be</pre> <pre class="line before"><span class="ws"> </span>wrapped to apply middleware.</pre> <pre class="line before"><span class="ws"> </span>"""</pre> <pre class="line current"><span class="ws"> </span>return self.wsgi_app(environ, start_response)</pre></div> </div> <li><div class="frame" id="frame-140703257649488"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>, line <em class="line">2080</em>, in <code class="function">wsgi_app</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>ctx.push()</pre> <pre class="line before"><span class="ws"> </span>response = self.full_dispatch_request()</pre> <pre class="line before"><span class="ws"> </span>except Exception as e:</pre> <pre class="line before"><span class="ws"> </span>error = e</pre> <pre class="line current"><span class="ws"> </span>response = self.handle_exception(e)</pre> <pre class="line after"><span class="ws"> </span>except: # noqa: B001</pre> <pre class="line after"><span class="ws"> </span>error = sys.exc_info()[1]</pre> <pre class="line after"><span class="ws"> </span>raise</pre> <pre class="line after"><span class="ws"> </span>return response(environ, start_response)</pre> <pre class="line after"><span class="ws"> </span>finally:</pre></div> </div> <li><div class="frame" id="frame-140703257649360"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>, line <em class="line">2077</em>, in <code class="function">wsgi_app</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>ctx = self.request_context(environ)</pre> <pre class="line before"><span class="ws"> </span>error: t.Optional[BaseException] = None</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>ctx.push()</pre> <pre class="line current"><span class="ws"> </span>response = self.full_dispatch_request()</pre> <pre class="line after"><span class="ws"> </span>except Exception as e:</pre> <pre class="line after"><span class="ws"> </span>error = e</pre> <pre class="line after"><span class="ws"> </span>response = self.handle_exception(e)</pre> <pre class="line after"><span class="ws"> </span>except: # noqa: B001</pre> <pre class="line after"><span class="ws"> </span>error = sys.exc_info()[1]</pre></div> </div> <li><div class="frame" id="frame-140703257649616"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>, line <em class="line">1525</em>, in <code class="function">full_dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>request_started.send(self)</pre> <pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre> <pre class="line before"><span class="ws"> </span>if rv is None:</pre> <pre class="line before"><span class="ws"> </span>rv = self.dispatch_request()</pre> <pre class="line before"><span class="ws"> </span>except Exception as e:</pre> <pre class="line current"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre> <pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_request(</pre> <pre class="line after"><span class="ws"> </span>self,</pre> <pre class="line after"><span class="ws"> </span>rv: t.Union[ResponseReturnValue, HTTPException],</pre></div> </div> <li><div class="frame" id="frame-140703257649744"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>, line <em class="line">1523</em>, in <code class="function">full_dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self.try_trigger_before_first_request_functions()</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>request_started.send(self)</pre> <pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre> <pre class="line before"><span class="ws"> </span>if rv is None:</pre> <pre class="line current"><span class="ws"> </span>rv = self.dispatch_request()</pre> <pre class="line after"><span class="ws"> </span>except Exception as e:</pre> <pre class="line after"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre> <pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_request(</pre></div> </div> <li><div class="frame" id="frame-140703257649872"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/flask/app.py"</cite>, line <em class="line">1509</em>, in <code class="function">dispatch_request</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>getattr(rule, "provide_automatic_options", False)</pre> <pre class="line before"><span class="ws"> </span>and req.method == "OPTIONS"</pre> <pre class="line before"><span class="ws"> </span>):</pre> <pre class="line before"><span class="ws"> </span>return self.make_default_options_response()</pre> <pre class="line before"><span class="ws"> </span># otherwise dispatch to the handler for that endpoint</pre> <pre class="line current"><span class="ws"> </span>return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def full_dispatch_request(self) -> Response:</pre> <pre class="line after"><span class="ws"> </span>"""Dispatches the request and on top of that performs request</pre> <pre class="line after"><span class="ws"> </span>pre and postprocessing as well as HTTP exception catching and</pre> <pre class="line after"><span class="ws"> </span>error handling.</pre></div> </div> <li><div class="frame" id="frame-140703257650128"> <h4>File <cite class="filename">"/data_fill_api/app.py"</cite>, line <em class="line">1548</em>, in <code class="function">get_oil_report_details</code></h4> <div class="source "><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"></span>@app.route('/put_oil_report_json', methods=['GET', 'POST'])</pre> <pre class="line before"><span class="ws"></span>def get_oil_report_details():</pre> <pre class="line before"><span class="ws"> </span>content = request.json</pre> <pre class="line current"><span class="ws"> </span>put_new_oil_report(content)</pre> <pre class="line after"><span class="ws"> </span>return 'True'</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span>def put_new_oil_report(content):</pre> <pre class="line after"><span class="ws"> </span>harmo_series = pd.read_json(content['harmo_json']).iloc[0]</pre></div> </div> <li><div class="frame" id="frame-140703257650256"> <h4>File <cite class="filename">"/data_fill_api/app.py"</cite>, line <em class="line">1573</em>, in <code class="function">put_new_oil_report</code></h4> <div class="source "><pre class="line before"><span class="ws"> </span>)</pre> <pre class="line before"><span class="ws"> </span>Harmonogram_row.oil_analysis_harmonogram_id_pkey = int(harmo_series.oil_analysis_harmonogram_id_pkey)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>db.session.add(Harmonogram_row)</pre> <pre class="line current"><span class="ws"> </span>db.session.commit()</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>for mc, row_series_meas in oil_meas_device_df.iterrows():</pre> <pre class="line after"><span class="ws"> </span>meas_oil_dev_row = OilMeasurementsDevice(</pre> <pre class="line after"><span class="ws"> </span>row_series_meas.harmo_id_fkey,</pre></div> </div> <li><div class="frame" id="frame-140703257650384"> <h4>File <cite class="filename">"<string>"</cite>, line <em class="line">2</em>, in <code class="function">commit</code></h4> <div class="source "></div> </div> <li><div class="frame" id="frame-140703257650640"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">1451</em>, in <code class="function">commit</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>"""</pre> <pre class="line before"><span class="ws"> </span>if self._transaction is None:</pre> <pre class="line before"><span class="ws"> </span>if not self._autobegin():</pre> <pre class="line before"><span class="ws"> </span>raise sa_exc.InvalidRequestError("No transaction is begun.")</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line current"><span class="ws"> </span>self._transaction.commit(_to_root=self.future)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def prepare(self):</pre> <pre class="line after"><span class="ws"> </span>"""Prepare the current transaction in progress for two phase commit.</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>If no transaction is in progress, this method raises an</pre></div> </div> <li><div class="frame" id="frame-140703257650768"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">829</em>, in <code class="function">commit</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>self._state = PREPARED</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def commit(self, _to_root=False):</pre> <pre class="line before"><span class="ws"> </span>self._assert_active(prepared_ok=True)</pre> <pre class="line before"><span class="ws"> </span>if self._state is not PREPARED:</pre> <pre class="line current"><span class="ws"> </span>self._prepare_impl()</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if self._parent is None or self.nested:</pre> <pre class="line after"><span class="ws"> </span>for conn, trans, should_commit, autoclose in set(</pre> <pre class="line after"><span class="ws"> </span>self._connections.values()</pre> <pre class="line after"><span class="ws"> </span>):</pre></div> </div> <li><div class="frame" id="frame-140703257650896"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">808</em>, in <code class="function">_prepare_impl</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if not self.session._flushing:</pre> <pre class="line before"><span class="ws"> </span>for _flush_guard in range(100):</pre> <pre class="line before"><span class="ws"> </span>if self.session._is_clean():</pre> <pre class="line before"><span class="ws"> </span>break</pre> <pre class="line current"><span class="ws"> </span>self.session.flush()</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>raise exc.FlushError(</pre> <pre class="line after"><span class="ws"> </span>"Over 100 subsequent flushes have occurred within "</pre> <pre class="line after"><span class="ws"> </span>"session.commit() - is an after_flush() hook "</pre> <pre class="line after"><span class="ws"> </span>"creating new objects?"</pre></div> </div> <li><div class="frame" id="frame-140703257651024"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">3444</em>, in <code class="function">flush</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if self._is_clean():</pre> <pre class="line before"><span class="ws"> </span>return</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>self._flushing = True</pre> <pre class="line current"><span class="ws"> </span>self._flush(objects)</pre> <pre class="line after"><span class="ws"> </span>finally:</pre> <pre class="line after"><span class="ws"> </span>self._flushing = False</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def _flush_warning(self, method):</pre> <pre class="line after"><span class="ws"> </span>util.warn(</pre></div> </div> <li><div class="frame" id="frame-140703257651152"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">3584</em>, in <code class="function">_flush</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>transaction.commit()</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>except:</pre> <pre class="line before"><span class="ws"> </span>with util.safe_reraise():</pre> <pre class="line current"><span class="ws"> </span>transaction.rollback(_capture_exception=True)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def bulk_save_objects(</pre> <pre class="line after"><span class="ws"> </span>self,</pre> <pre class="line after"><span class="ws"> </span>objects,</pre> <pre class="line after"><span class="ws"> </span>return_defaults=False,</pre></div> </div> <li><div class="frame" id="frame-140703257651280"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py"</cite>, line <em class="line">72</em>, in <code class="function">__exit__</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>exc_type, exc_value, exc_tb = self._exc_info</pre> <pre class="line before"><span class="ws"> </span>self._exc_info = None # remove potential circular references</pre> <pre class="line before"><span class="ws"> </span>if not self.warn_only:</pre> <pre class="line before"><span class="ws"> </span>compat.raise_(</pre> <pre class="line before"><span class="ws"> </span>exc_value,</pre> <pre class="line current"><span class="ws"> </span>with_traceback=exc_tb,</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>if not compat.py3k and self._exc_info and self._exc_info[1]:</pre> <pre class="line after"><span class="ws"> </span># emulate Py3K's behavior of telling us when an exception</pre> <pre class="line after"><span class="ws"> </span># occurs in an exception handler.</pre></div> </div> <li><div class="frame" id="frame-140703257651408"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py"</cite>, line <em class="line">210</em>, in <code class="function">raise_</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># intermediary exception does not change, but we can't figure</pre> <pre class="line before"><span class="ws"> </span># that out.</pre> <pre class="line before"><span class="ws"> </span>exception.__cause__ = replace_context</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line current"><span class="ws"> </span>raise exception</pre> <pre class="line after"><span class="ws"> </span>finally:</pre> <pre class="line after"><span class="ws"> </span># credit to</pre> <pre class="line after"><span class="ws"> </span># https://cosmicpercolator.com/2016/01/13/exception-leaks-in-python-2-and-3/</pre> <pre class="line after"><span class="ws"> </span># as the __traceback__ object creates a cycle</pre> <pre class="line after"><span class="ws"> </span>del exception, replace_context, from_, with_traceback</pre></div> </div> <li><div class="frame" id="frame-140703257651536"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py"</cite>, line <em class="line">3544</em>, in <code class="function">_flush</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>flush_context.transaction = transaction = self.begin(_subtrans=True)</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line before"><span class="ws"> </span>self._warn_on_events = True</pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line current"><span class="ws"> </span>flush_context.execute()</pre> <pre class="line after"><span class="ws"> </span>finally:</pre> <pre class="line after"><span class="ws"> </span>self._warn_on_events = False</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>self.dispatch.after_flush(self, flush_context)</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-140703257650512"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py"</cite>, line <em class="line">456</em>, in <code class="function">execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>while set_:</pre> <pre class="line before"><span class="ws"> </span>n = set_.pop()</pre> <pre class="line before"><span class="ws"> </span>n.execute_aggregate(self, set_)</pre> <pre class="line before"><span class="ws"> </span>else:</pre> <pre class="line before"><span class="ws"> </span>for rec in topological.sort(self.dependencies, postsort_actions):</pre> <pre class="line current"><span class="ws"> </span>rec.execute(self)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def finalize_flush_changes(self):</pre> <pre class="line after"><span class="ws"> </span>"""Mark processed objects as clean / deleted after a successful</pre> <pre class="line after"><span class="ws"> </span>flush().</pre> <pre class="line after"><span class="ws"></span> </pre></div> </div> <li><div class="frame" id="frame-140703257651664"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py"</cite>, line <em class="line">633</em>, in <code class="function">execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>@util.preload_module("sqlalchemy.orm.persistence")</pre> <pre class="line before"><span class="ws"> </span>def execute(self, uow):</pre> <pre class="line before"><span class="ws"> </span>util.preloaded.orm_persistence.save_obj(</pre> <pre class="line before"><span class="ws"> </span>self.mapper,</pre> <pre class="line before"><span class="ws"> </span>uow.states_for_mapper_hierarchy(self.mapper, False, False),</pre> <pre class="line current"><span class="ws"> </span>uow,</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def per_state_flush_actions(self, uow):</pre> <pre class="line after"><span class="ws"> </span>states = list(</pre> <pre class="line after"><span class="ws"> </span>uow.states_for_mapper_hierarchy(self.mapper, False, False)</pre></div> </div> <li><div class="frame" id="frame-140703257651792"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py"</cite>, line <em class="line">250</em>, in <code class="function">save_obj</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>_emit_insert_statements(</pre> <pre class="line before"><span class="ws"> </span>base_mapper,</pre> <pre class="line before"><span class="ws"> </span>uowtransaction,</pre> <pre class="line before"><span class="ws"> </span>mapper,</pre> <pre class="line before"><span class="ws"> </span>table,</pre> <pre class="line current"><span class="ws"> </span>insert,</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>_finalize_insert_update_commands(</pre> <pre class="line after"><span class="ws"> </span>base_mapper,</pre> <pre class="line after"><span class="ws"> </span>uowtransaction,</pre></div> </div> <li><div class="frame" id="frame-140703257651920"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py"</cite>, line <em class="line">1098</em>, in <code class="function">_emit_insert_statements</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># so we have to post-fetch / use lastrowid anyway.</pre> <pre class="line before"><span class="ws"> </span>records = list(records)</pre> <pre class="line before"><span class="ws"> </span>multiparams = [rec[2] for rec in records]</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>c = connection._execute_20(</pre> <pre class="line current"><span class="ws"> </span>statement, multiparams, execution_options=execution_options</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if bookkeeping:</pre> <pre class="line after"><span class="ws"> </span>for (</pre> <pre class="line after"><span class="ws"> </span>(</pre></div> </div> <li><div class="frame" id="frame-140703257652048"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1705</em>, in <code class="function">_execute_20</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>except AttributeError as err:</pre> <pre class="line before"><span class="ws"> </span>util.raise_(</pre> <pre class="line before"><span class="ws"> </span>exc.ObjectNotExecutableError(statement), replace_context=err</pre> <pre class="line before"><span class="ws"> </span>)</pre> <pre class="line before"><span class="ws"> </span>else:</pre> <pre class="line current"><span class="ws"> </span>return meth(self, args_10style, kwargs_10style, execution_options)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def exec_driver_sql(</pre> <pre class="line after"><span class="ws"> </span>self, statement, parameters=None, execution_options=None</pre> <pre class="line after"><span class="ws"> </span>):</pre> <pre class="line after"><span class="ws"> </span>r"""Executes a SQL statement construct and returns a</pre></div> </div> <li><div class="frame" id="frame-140703257652304"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py"</cite>, line <em class="line">335</em>, in <code class="function">_execute_on_connection</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>def _execute_on_connection(</pre> <pre class="line before"><span class="ws"> </span>self, connection, multiparams, params, execution_options, _force=False</pre> <pre class="line before"><span class="ws"> </span>):</pre> <pre class="line before"><span class="ws"> </span>if _force or self.supports_execution:</pre> <pre class="line before"><span class="ws"> </span>return connection._execute_clauseelement(</pre> <pre class="line current"><span class="ws"> </span>self, multiparams, params, execution_options</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>raise exc.ObjectNotExecutableError(self)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def unique_params(self, *optionaldict, **kwargs):</pre></div> </div> <li><div class="frame" id="frame-140703257652432"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1582</em>, in <code class="function">_execute_clauseelement</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>execution_options,</pre> <pre class="line before"><span class="ws"> </span>compiled_sql,</pre> <pre class="line before"><span class="ws"> </span>distilled_params,</pre> <pre class="line before"><span class="ws"> </span>elem,</pre> <pre class="line before"><span class="ws"> </span>extracted_params,</pre> <pre class="line current"><span class="ws"> </span>cache_hit=cache_hit,</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"> </span>if has_events:</pre> <pre class="line after"><span class="ws"> </span>self.dispatch.after_execute(</pre> <pre class="line after"><span class="ws"> </span>self,</pre> <pre class="line after"><span class="ws"> </span>elem,</pre></div> </div> <li><div class="frame" id="frame-140703257652560"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1944</em>, in <code class="function">_execute_context</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># close us now</pre> <pre class="line before"><span class="ws"> </span>branched.close()</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>except BaseException as e:</pre> <pre class="line before"><span class="ws"> </span>self._handle_dbapi_exception(</pre> <pre class="line current"><span class="ws"> </span>e, statement, parameters, cursor, context</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>return result</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def _cursor_execute(self, cursor, statement, parameters, context=None):</pre></div> </div> <li><div class="frame" id="frame-140703257652688"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">2125</em>, in <code class="function">_handle_dbapi_exception</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>if newraise:</pre> <pre class="line before"><span class="ws"> </span>util.raise_(newraise, with_traceback=exc_info[2], from_=e)</pre> <pre class="line before"><span class="ws"> </span>elif should_wrap:</pre> <pre class="line before"><span class="ws"> </span>util.raise_(</pre> <pre class="line current"><span class="ws"> </span>sqlalchemy_exception, with_traceback=exc_info[2], from_=e</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"> </span>else:</pre> <pre class="line after"><span class="ws"> </span>util.raise_(exc_info[1], with_traceback=exc_info[2])</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>finally:</pre></div> </div> <li><div class="frame" id="frame-140703257652816"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py"</cite>, line <em class="line">210</em>, in <code class="function">raise_</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span># intermediary exception does not change, but we can't figure</pre> <pre class="line before"><span class="ws"> </span># that out.</pre> <pre class="line before"><span class="ws"> </span>exception.__cause__ = replace_context</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>try:</pre> <pre class="line current"><span class="ws"> </span>raise exception</pre> <pre class="line after"><span class="ws"> </span>finally:</pre> <pre class="line after"><span class="ws"> </span># credit to</pre> <pre class="line after"><span class="ws"> </span># https://cosmicpercolator.com/2016/01/13/exception-leaks-in-python-2-and-3/</pre> <pre class="line after"><span class="ws"> </span># as the __traceback__ object creates a cycle</pre> <pre class="line after"><span class="ws"> </span>del exception, replace_context, from_, with_traceback</pre></div> </div> <li><div class="frame" id="frame-140703257652944"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py"</cite>, line <em class="line">1901</em>, in <code class="function">_execute_context</code></h4> <div class="source library"><pre class="line before"><span class="ws"> </span>if fn(cursor, statement, parameters, context):</pre> <pre class="line before"><span class="ws"> </span>evt_handled = True</pre> <pre class="line before"><span class="ws"> </span>break</pre> <pre class="line before"><span class="ws"> </span>if not evt_handled:</pre> <pre class="line before"><span class="ws"> </span>self.dialect.do_execute(</pre> <pre class="line current"><span class="ws"> </span>cursor, statement, parameters, context</pre> <pre class="line after"><span class="ws"> </span>)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>if self._has_events or self.engine._has_events:</pre> <pre class="line after"><span class="ws"> </span>self.dispatch.after_cursor_execute(</pre> <pre class="line after"><span class="ws"> </span>self,</pre></div> </div> <li><div class="frame" id="frame-140703257653072"> <h4>File <cite class="filename">"/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py"</cite>, line <em class="line">736</em>, in <code class="function">do_execute</code></h4> <div class="source library"><pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def do_executemany(self, cursor, statement, parameters, context=None):</pre> <pre class="line before"><span class="ws"> </span>cursor.executemany(statement, parameters)</pre> <pre class="line before"><span class="ws"></span> </pre> <pre class="line before"><span class="ws"> </span>def do_execute(self, cursor, statement, parameters, context=None):</pre> <pre class="line current"><span class="ws"> </span>cursor.execute(statement, parameters)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def do_execute_no_params(self, cursor, statement, context=None):</pre> <pre class="line after"><span class="ws"> </span>cursor.execute(statement)</pre> <pre class="line after"><span class="ws"></span> </pre> <pre class="line after"><span class="ws"> </span>def is_disconnect(self, e, connection, cursor):</pre></div> </div> </ul> <blockquote>sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) BŁĄD: wstawianie lub modyfikacja na tabeli "oil_analysis_harmonogram" narusza klucz obcy "FK_device_id" DETAIL: Klucz (device_id_fkey)=(69436) nie występuje w tabeli "devices". [SQL: INSERT INTO cbm.oil_analysis_harmonogram (oil_analysis_harmonogram_id_pkey, ship_id_fkey, device_id_fkey, report_number, report_type_id_fkey) VALUES (%(oil_analysis_harmonogram_id_pkey)s, %(ship_id_fkey)s, %(device_id_fkey)s, %(report_number)s, %(report_type_id_fkey)s)] [parameters: {'oil_analysis_harmonogram_id_pkey': 688, 'ship_id_fkey': 344, 'device_id_fkey': '69436', 'report_number': '18241482127', 'report_type_id_fkey': '292'}] (Background on this error at: https://sqlalche.me/e/14/gkpj) </blockquote> </div> <div class="plain"> <p> This is the Copy/Paste friendly version of the traceback. </p> <textarea cols="50" rows="10" name="code" readonly>Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1901, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) psycopg2.errors.ForeignKeyViolation: BŁĄD: wstawianie lub modyfikacja na tabeli "oil_analysis_harmonogram" narusza klucz obcy "FK_device_id" DETAIL: Klucz (device_id_fkey)=(69436) nie występuje w tabeli "devices". The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2095, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2080, in wsgi_app response = self.handle_exception(e) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2077, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1525, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1523, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1509, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/data_fill_api/app.py", line 1548, in get_oil_report_details put_new_oil_report(content) File "/data_fill_api/app.py", line 1573, in put_new_oil_report db.session.commit() File "<string>", line 2, in commit File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1451, in commit self._transaction.commit(_to_root=self.future) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 829, in commit self._prepare_impl() File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 808, in _prepare_impl self.session.flush() File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 3444, in flush self._flush(objects) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 3584, in _flush transaction.rollback(_capture_exception=True) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 72, in __exit__ with_traceback=exc_tb, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 210, in raise_ raise exception File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 3544, in _flush flush_context.execute() File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute rec.execute(self) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 633, in execute uow, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 250, in save_obj insert, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1098, in _emit_insert_statements statement, multiparams, execution_options=execution_options File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_20 return meth(self, args_10style, kwargs_10style, execution_options) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 335, in _execute_on_connection self, multiparams, params, execution_options File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1582, in _execute_clauseelement cache_hit=cache_hit, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1944, in _execute_context e, statement, parameters, cursor, context File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2125, in _handle_dbapi_exception sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 210, in raise_ raise exception File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1901, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) BŁĄD: wstawianie lub modyfikacja na tabeli "oil_analysis_harmonogram" narusza klucz obcy "FK_device_id" DETAIL: Klucz (device_id_fkey)=(69436) nie występuje w tabeli "devices". [SQL: INSERT INTO cbm.oil_analysis_harmonogram (oil_analysis_harmonogram_id_pkey, ship_id_fkey, device_id_fkey, report_number, report_type_id_fkey) VALUES (%(oil_analysis_harmonogram_id_pkey)s, %(ship_id_fkey)s, %(device_id_fkey)s, %(report_number)s, %(report_type_id_fkey)s)] [parameters: {'oil_analysis_harmonogram_id_pkey': 688, 'ship_id_fkey': 344, 'device_id_fkey': '69436', 'report_number': '18241482127', 'report_type_id_fkey': '292'}] (Background on this error at: https://sqlalche.me/e/14/gkpj) </textarea> </div> <div class="explanation"> The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error. <span class="nojavascript"> If you enable JavaScript you can also use additional features such as code execution (if the evalex feature is enabled), automatic pasting of the exceptions and much more.</span> </div> <div class="footer"> Brought to you by <strong class="arthur">DON'T PANIC</strong>, your friendly Werkzeug powered traceback interpreter. </div> </div> <div class="pin-prompt"> <div class="inner"> <h3>Console Locked</h3> <p> The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server. <form> <p>PIN: <input type=text name=pin size=14> <input type=submit name=btn value="Confirm Pin"> </form> </div> </div> </body> </html> <!-- Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1901, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) psycopg2.errors.ForeignKeyViolation: BŁĄD: wstawianie lub modyfikacja na tabeli "oil_analysis_harmonogram" narusza klucz obcy "FK_device_id" DETAIL: Klucz (device_id_fkey)=(69436) nie występuje w tabeli "devices". The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2095, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2080, in wsgi_app response = self.handle_exception(e) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2077, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1525, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1523, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1509, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/data_fill_api/app.py", line 1548, in get_oil_report_details put_new_oil_report(content) File "/data_fill_api/app.py", line 1573, in put_new_oil_report db.session.commit() File "<string>", line 2, in commit File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1451, in commit self._transaction.commit(_to_root=self.future) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 829, in commit self._prepare_impl() File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 808, in _prepare_impl self.session.flush() File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 3444, in flush self._flush(objects) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 3584, in _flush transaction.rollback(_capture_exception=True) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 72, in __exit__ with_traceback=exc_tb, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 210, in raise_ raise exception File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 3544, in _flush flush_context.execute() File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute rec.execute(self) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 633, in execute uow, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 250, in save_obj insert, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1098, in _emit_insert_statements statement, multiparams, execution_options=execution_options File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_20 return meth(self, args_10style, kwargs_10style, execution_options) File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 335, in _execute_on_connection self, multiparams, params, execution_options File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1582, in _execute_clauseelement cache_hit=cache_hit, File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1944, in _execute_context e, statement, parameters, cursor, context File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2125, in _handle_dbapi_exception sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 210, in raise_ raise exception File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1901, in _execute_context cursor, statement, parameters, context File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) BŁĄD: wstawianie lub modyfikacja na tabeli "oil_analysis_harmonogram" narusza klucz obcy "FK_device_id" DETAIL: Klucz (device_id_fkey)=(69436) nie występuje w tabeli "devices". [SQL: INSERT INTO cbm.oil_analysis_harmonogram (oil_analysis_harmonogram_id_pkey, ship_id_fkey, device_id_fkey, report_number, report_type_id_fkey) VALUES (%(oil_analysis_harmonogram_id_pkey)s, %(ship_id_fkey)s, %(device_id_fkey)s, %(report_number)s, %(report_type_id_fkey)s)] [parameters: {'oil_analysis_harmonogram_id_pkey': 688, 'ship_id_fkey': 344, 'device_id_fkey': '69436', 'report_number': '18241482127', 'report_type_id_fkey': '292'}] (Background on this error at: https://sqlalche.me/e/14/gkpj) -->
|