O'Reilly logo

Learning Sinatra by Manoj Sehrawat, Sudeep Agarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

When to use an ORM

Using an ORM has a lot of benefits over using standard SQL directly. Let's discuss some of them:

  1. Quick development: One needs to create tables manually and manage them when using SQL directly. Using an ORM reduces all such overheads.

    We can define classes that correspond to the table structure and every time we restart the application, the database is updated.

  2. Handling errors and transactions: Instead of writing SQL statements to manage transactions and handle errors, we can write simple Ruby code to do the same.
  3. Independent of the DBMS: ORMs are independent of the DBMS used. We can use the exact same code to communicate with any of the DBMS. We will just need to specify it while defining the connection and everything else will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required