Perl ORM - DBIx::Class

Perl database ORM

DBIx::Class - database object relational mapper (ORM)

Making database queries easy and code clean

DBIx::Class is a powerful object relational mapper (ORM), transparently converting results from a database into result set objects (a group of records) and result objects (a single record) and back again. With automatic database introspection DBIx::Class enables developers to focus on using and extending these objects without having to write and maintain SQL, making development faster, maintainable and encouraging code reuse.

Using Perl's DBI (database interface) DBIx::Class is able to talk to many different types of database. These include: Oracle, SQL Server, MySQL, PostgreSQL, SQLite, ODBC, DB2 and even CSV.

DBIx::Class's result set objects are customizable, you can create specific search methods which are then chainable. For example:

@web_employees = $employees_result_set->active()->in_department('web')->all();

Having defined active() and in_department() as part of the result set, these can now be re-used elsewhere making code readable and maintainable.

Additionally developers can insert business logic at the individual result object, for example a new employee or an employee who leaves could trigger an email that would automatically be sent to the relevant department to perform an action, IT may be required to create or delete an account, or payroll informed of employment status. Providing business logic at a core level promotes a single location for interactions with any individual record accessible from any point in the code base.

Quotes

Resources:

Alternative Perl ORMs:

Article Author

Leo Lapworth