Python Forum

Full Version: SQLAlchemy, log only one record from failed insert
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, sometimes I can find in logs following long tracebacks:

... (part of Traceback is skipped) ...
"/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py\", line 948, in execute\n    return meth(self, multiparams, params)\n
... (part of Traceback is skipped) ...
File \"/usr/local/lib/python3.6/site-packages/mysql/connector/connection.py\", line 396, in _handle_result\n    raise errors.get_exception(packet)\nsqlalchemy.exc.DataError: (mysql.connector.errors.DataError) 1264 (22003): Out of range value for column 'tlm_1' at row 722
... Then goes very long sql query with inserting hundreds of records ...
Structure of query:
INSERT INTO <table> <fields> VALUES (<row1>, <row2>, ... )
The question is: is there any possibility to log only record (row) which is failed and not whole query with almost 200 rows?