Sequel is a relational database toolkit for Ruby that provides object-relational mapping, a fluent SQL query builder, and schema migration capabilities. It maps database tables to Ruby classes with support for associations, validations, lifecycle hooks, and eager loading, offering a comprehensive ORM layer for building data-centric applications.
Sequel distinguishes itself through a plugin-based extension architecture that allows composable customization of models, databases, and datasets without relying on deep inheritance hierarchies. It includes a thread-safe connection pool with support for database sharding, read/write splitting across replicas, and nested transactions with savepoint rollback. The library also provides a schema migration DSL with reversible steps, automation tools for database content copying and an interactive shell, and fine-grained control over connection management for multi-server setups.
Beyond its core ORM and query capabilities, Sequel includes a data validation framework with built-in helpers and schema-driven validation generation, a lifecycle callback system covering create, update, destroy, and transaction events, and serialization support for CSV, JSON, XML, and other formats. It offers model instance caching, prepared statement execution, and testing utilities such as transaction-based test isolation and truncation-based cleanup. The library also provides logging, structured error details, and mass assignment protection for security.