A pure functional JDBC layer for Scala
open sourceMITfree
doobie is a pure functional JDBC layer for Scala and Cats, a Typelevel project. It isn't an ORM or a relational algebra: you write SQL in a sql string interpolator with typed parameters, map the rows to case classes, and compose database programs as values that a transactor runs. It can typecheck queries against the live database schema in unit tests, builds statements from fragments, handles errors, logging and tracing with otel4s, and supports SQL arrays and custom type mappings, with extensions for PostgreSQL and H2.
Problems it solves
- query a SQL database from Scala in a purely functional way with Cats Effect
- write plain SQL in Scala but get type-checked results instead of an ORM
- check in my tests that my SQL queries match the database schema
- use JDBC from Scala without side effects leaking everywhere
Features
- SQL in a string interpolator with typed parameters
- rows mapped to case classes
- database programs as composable values run by a transactor
- typecheck queries against the live schema in unit tests
- statement fragments
- error handling and logging
- tracing with otel4s
- SQL arrays and custom type mappings
- extensions for PostgreSQL and H2
Capabilities
| Has official SDKs | plan not known |
|---|
Alternatives
The same job
These do what doobie does.
- Slick Functional Relational Mapping for Scala