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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.