18 hours ago
- Esqueleto is a type-safe library for writing SQL queries in Haskell, building on Persistent data mappings.
- It allows nearly raw SQL queries with compile-time type checking to prevent errors.
- The tutorial uses a sample chinook.db SQLite database and scaffolds a Haskell project with Persistent and Esqueleto.
- Covers basic select queries: arithmetic, selecting from tables, limiting results, sorting, and extracting fields.
- Filters include WHERE, DISTINCT, LIKE, set membership (IN_), subqueries, and null checks (IS NULL, IS NOT NULL).
- Joins: inner join between tables, and multi-table joins using the new Esqueleto style with monadic bind and pattern matching.
- Data aggregation: GROUP BY, COUNT, HAVING for filtering grouped results.
- The new style (Database.Esqueleto.Experimental) is recommended and safer than the legacy style.