DEV.co
Open-Source Databases · typelevel

doobie

doobie is a Scala library that provides a functional programming approach to working with databases through JDBC. It abstracts away raw SQL handling while maintaining type safety and composability, making database interactions cleaner and more maintainable for Scala teams.

Source: GitHub — github.com/typelevel/doobie
2.2k
GitHub stars
378
Forks
Scala
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorytypelevel/doobie
Ownertypelevel
Primary languageScala
LicenseMIT — OSI-approved
Stars2.2k
Forks378
Open issues135
Latest releasev1.0.0-RC13 (2026-06-12)
Last updated2026-07-06
Sourcehttps://github.com/typelevel/doobie

What doobie is

doobie is a pure functional JDBC abstraction layer for Scala built on the Typelevel ecosystem, offering composable SQL queries with compile-time type checking and functional composition primitives. It bridges imperative JDBC drivers with functional programming idioms, enabling safe database operations without raw SQL string manipulation.

Quickstart

Get the doobie source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/typelevel/doobie.gitcd doobie# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Type-safe SQL composition in Scala microservices

Build database layers where queries are composable, type-checked at compile time, and refactored safely. Ideal for teams already using Typelevel libraries (Cats, FS2) who want database access to follow functional patterns.

Migration from raw JDBC or anemic ORMs

Replace boilerplate-heavy JDBC code or object-relational mappers with a lighter, more functional abstraction that reduces impedance mismatch while preserving direct SQL control.

Data-intensive Scala applications with strict correctness requirements

Teams needing strong compile-time guarantees and composability for complex queries, batch operations, and transactional logic in financial, analytics, or high-reliability systems.

Implementation considerations

  • Requires Scala 2.13+ or Scala 3; ensure project Scala version alignment before adopting. Latest release is RC stage (v1.0.0-RC13), so production use should evaluate stability.
  • Strong familiarity with Cats/FS2 idioms (IO, Resource, Stream) is necessary for effective query composition and resource management.
  • Query validation happens at compile time where possible; plan testing strategy to cover runtime parameter binding and database-specific SQL dialects.
  • Connection pooling, transaction management, and threading semantics are delegated to underlying JDBC driver and Cats-Effect runtime—ensure those are properly configured.
  • SQL fragments are parameterized to prevent injection, but custom fragments require careful review to maintain safety guarantees.

When to avoid it — and what to weigh

  • Polyglot teams unfamiliar with Scala FP patterns — doobie's functional programming model (monads, applicatives, composition) has a steep learning curve. Avoid if team members lack Scala FP experience or require an ORM that works across languages.
  • Schema-first or rapid prototyping workflows — doobie requires explicit SQL definition; it offers no code generation from schema. Better alternatives exist if you need automatic model generation or quick schema exploration.
  • Non-JVM or non-SQL databases — doobie is JDBC-centric and Scala-only. NoSQL, GraphQL, or non-JVM platforms require different tooling.
  • Projects requiring minimal dependencies — doobie depends on Cats, FS2, and other Typelevel libraries. Projects requiring a lightweight standalone library should consider alternatives.

License & commercial use

doobie is released under the MIT License, a permissive OSI-approved license allowing commercial use, modification, and distribution with minimal restrictions.

MIT License permits commercial use without restriction. No corporate support, funding model, or dual-licensing arrangement is evident from the data. Review the LICENSE file in the repository to confirm; no other commercial terms are stated.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

Query parameterization is built-in and prevents SQL injection when used as documented. JDBC driver and underlying database security are outside doobie's scope—ensure driver versions, SSL/TLS, and credential storage are properly managed. Connection pooling configuration (e.g., timeouts, authentication) should follow security best practices. No known published CVEs noted in the data; audit dependency chain (Cats, FS2) for vulnerabilities as part of supply-chain review.

Alternatives to consider

Slick

Scala-native query DSL with code generation from schema; less pure functional but more ergonomic for rapid development. Steeper learning curve for functional composition.

Quill

Compile-time query optimization with compile-time SQL generation; compile-time macro safety similar to doobie. Supports Scala 3 and multiple backends (SQL, Cassandra, etc.); larger ecosystem.

Raw JDBC with HikariCP

Minimal abstraction; maximum control over SQL. Suitable for teams prioritizing simplicity and avoiding functional programming overhead, but sacrifices type safety and composability.

Software development agency

Build on doobie with DEV.co software developers

doobie is ideal for Scala teams seeking functional programming patterns in database layers. Evaluate it for microservices, data pipelines, and applications where compile-time safety and composability matter. Start with the quick-start example and join the Typelevel Discord community.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

doobie FAQ

Is doobie production-ready?
Latest release is v1.0.0-RC13 (June 2026), pre-1.0. RC status suggests near-final stability but not yet officially released. Evaluate release notes and conduct pre-production testing before committing to mission-critical systems.
Do I need to know Cats to use doobie?
Yes. doobie is built on Cats monads and applicatives. Strong familiarity with IO, Option, Either, and monad composition is essential. Learning curve is steep for non-FP Scala developers.
Can doobie work with async/non-blocking databases?
doobie uses JDBC, which is inherently blocking. Async support comes from Cats-Effect thread pools and FS2 streaming. For native async databases, alternatives like Quill or dedicated async drivers are better suited.
What databases does doobie support?
Any database with a JDBC driver (PostgreSQL, MySQL, Oracle, H2, etc.). doobie itself is database-agnostic; driver and SQL dialect compatibility are user's responsibility.

Work with a software development agency

Adopting doobie is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source databases software in production.

Ready to adopt type-safe database access?

doobie is ideal for Scala teams seeking functional programming patterns in database layers. Evaluate it for microservices, data pipelines, and applications where compile-time safety and composability matter. Start with the quick-start example and join the Typelevel Discord community.