Issue
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.
Solution
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.)
Answered By - Petr Viktorin Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.