Reputation: 17321
How do I do error handling with something like this in RoR:
conn = Person.connection
conn.execute(sql_stmt)
What if there were errors while executing the SQL?
Upvotes: 0
Views: 225
Reputation: 434665
The execute
method is just a wrapper for the connection's query
method and that will raise an Mysql::Error
exception if something is wrong. If you use mysql2 instead of the older mysql gem, then I think you'll get a Mysql2::Error
exception.
Upvotes: 1