Giter Site home page Giter Site logo

doobie's Introduction

doobie

Travis CI Join the chat at https://gitter.im/tpolecat/doobie Maven Central

doobie is a pure functional JDBC layer for Scala. It is not an ORM, nor is it a relational algebra; it just provides a principled way to construct programs (and higher-level libraries) that use JDBC. doobie introduces very few new abstractions; if you are familiar with basic scalaz typeclasses like Functor and Monad you should have no trouble here.

For common use cases doobie provides a minimal but expressive high-level API:

import doobie.imports._, scalaz.effect.IO

val xa = DriverManagerTransactor[IO](
  "org.postgresql.Driver", "jdbc:postgresql:world", "postgres", ""
)

case class Country(code: String, name: String, population: Long)

def find(n: String): ConnectionIO[Option[Country]] = 
  sql"select code, name, population from country where name = $n".query[Country].option

// And then

scala> find("France").transact(xa).unsafePerformIO
res0: Option[Country] = Some(Country(FRA,France,59225700))

doobie is a Typelevel project. This means we embrace pure, typeful, functional programming, and provide a safe and friendly environment for teaching, learning, and contributing as described in the Typelevel Code of Conduct.

Quick Start

The current release is 0.2.3, which works on Scala 2.10.5 and 2.11 with

  • scalaz 7.1
  • scalaz-stream 0.7.2a โ† important: later versions are not compatible (yet)
  • shapeless 2.2

You should expect minor breaking changes for at least the next few versions, although these will be documented and kept to a minimum. To use doobie you need to add the following to your build.sbt.

libraryDependencies += "org.tpolecat" %% "doobie-core" % "0.2.3"

If you are using Scala 2.10.5 you must also add the paradise compiler plugin.

addCompilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.full)

It is likely that you will want one or more add-on libraries. doobie provides the following, which have the same version as doobie-core and are released together.

  • doobie-contrib-h2 for H2-specific type mappings.
  • doobie-contrib-hikari for HikariCP connection pooling.
  • doobie-contrib-postgresql for PostgreSQL-specific type mappings.
  • doobie-contrib-specs2 for specs2 support for typechecking queries.

See the book of doobie for more information on these add-ons.

Documentation and Support

  • See the changelog for an overview of changes in this and previous versions.
  • Behold the book of doobie โ† start here
  • The scaladoc will be handy once you get your feet wet.
  • There is also the source. If you're here you know where to look. Check the examples.
  • If you have comments or run into trouble, please file an issue.
  • Find tpolecat on the FreeNode #scala channel, or join the Gitter Channel.

Presentations, Blog Posts, etc.

Listed newest first. If you have given a presentation or have written a blog post on doobie, let me know and I'll add it to this list.

doobie's People

Contributors

tpolecat avatar guersam avatar aryairani avatar mdmoss avatar gseitz avatar milessabin avatar wedens avatar j-keck avatar ant8e avatar coltfred avatar etorreborre avatar fthomas avatar kryptt avatar

Watchers

Reggie Perry avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.