I want to modify sqlalchemy settings to raise an exception on warnings.
For example, when I insert a larger amount of data in a field than the defined column length, mysql will truncate the data, insert the truncated data into the field and issue a warning.
Instead of the warning, I would like sqlalchemy to raise an appropriate error on behalf of mysql.
To turn the “oh by the way I mangled your data” warnings into errors,
set an appropriate server mode for MySQL.
With SQLAlchemy, you should choose ANSI, as you probably don't have to worry about your old queries being compatible with some brokenMySQL-specific behavior.
See the SQLAlchemy docs on how to do it.
(Also consider using a database that's strict by default. Postgres comes to mind.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With