A tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.
xuwei-k fix warning in Scala 2.13.0-M5 (#938)
- scala/scala@1f1912d
- https://travis-ci.org/scalikejdbc/scalikejdbc/jobs/427930615#L777

[warn]/home/travis/build/scalikejdbc/scalikejdbc/scalikejdbc-mapper-generator-core/src/main/scala/scalikejdbc/mapper/GeneratorConfig.scala:67:43: method + in class Char is deprecated (since 2.13.0): Adding a number and a String is deprecated. Convert the number to a String with `toString` first to call +
[warn]      camelCase => camelCase.head.toLower + camelCase.tail
[warn]                                          ^
Latest commit 2765dbe Sep 15, 2018
Failed to load latest commit information.
notes Add 3.3.1 release note Aug 9, 2018
project sbt 1.2.1 Aug 7, 2018
sandbox sbt 1.2.1 Aug 7, 2018
scalikejdbc-cli sbt 1.2.1 Aug 7, 2018
scalikejdbc-config Load default value instead of false if isn’t included in config Feb 15, 2018
scalikejdbc-core/src Fix several minor typos detected by github.com/client9/misspell Aug 8, 2018
scalikejdbc-interpolation-macro/src/main/scala/scalikejdbc drop Scala 2.10 and sbt 0.13 support Jan 23, 2018
scalikejdbc-interpolation Restore QueryInterfaceSpec which is referred from the official website Aug 3, 2018
scalikejdbc-joda-time/src Fix several minor typos detected by github.com/client9/misspell Aug 8, 2018
scalikejdbc-library/src s/Traversable/Iterable/ May 28, 2018
scalikejdbc-mapper-generator-core fix warning in Scala 2.13.0-M5 (#938) Sep 15, 2018
scalikejdbc-mapper-generator add tableNameToSyntaxVariableName Jun 10, 2018
scalikejdbc-streams Scala 2.13.0-M4 Jun 16, 2018
scalikejdbc-syntax-support-macro/src Scala 2.13.0-M4 May 27, 2018
scalikejdbc-test Fix several minor typos detected by github.com/client9/misspell Aug 8, 2018
scripts version 3.3.0 Jul 25, 2018
tools-support/intellij/templates scalikejdbc.SQLInterpolation is deprecated Dec 31, 2014
.gitignore Ignore ensime related files Sep 22, 2016
.travis.yml Scala 2.13.0-M5 Sep 12, 2018
CONTRIBUTING.md Start 3.4 dev Jul 25, 2018
LICENSE.txt Update copyright Feb 28, 2015
build.sbt Scala 2.13.0-M5 Sep 12, 2018
logo.png Updated logo Jun 16, 2014
readme.md fix search.maven.org url Aug 20, 2018
team-rules.md remove sbt-pgp setting in team-rules.md Jan 19, 2018
travis.sh Scala 2.12.6 Apr 27, 2018
travis_before.sh should not execute "git add" multiple times Mar 20, 2015



Just write SQL and get things done!

ScalikeJDBC is a tidy SQL-based DB access library for Scala that naturally wraps JDBC and provides easy-to-use APIs.

ScalikeJDBC is practical and production-ready. Use this library for your real projects.


Build Status Maven Central

Gitter Chat for Casual Q&A

  • English: Gitter
  • 日本語 (Japanese): Gitter

Getting Started

Just add ScalikeJDBC, a JDBC driver, and an slf4j implementation to your sbt build settings:

libraryDependencies ++= Seq(
  "org.scalikejdbc" %% "scalikejdbc"        % "3.3.+",
  "com.h2database"  %  "h2"                 % "1.4.+",
  "ch.qos.logback"  %  "logback-classic"    % "1.2.+"

If you're a Play2 user, take a look at play-support project, too:


First example

After adding the above dependencies to your build.sbt, run sbt console and execute the following code:

import scalikejdbc._

// initialize JDBC driver & connection pool
ConnectionPool.singleton("jdbc:h2:mem:hello", "user", "pass")

// ad-hoc session provider on the REPL
implicit val session = AutoSession

// table creation, you can run DDL by using #execute as same as JDBC
create table members (
  id serial not null primary key,
  name varchar(64),
  created_at timestamp not null

// insert initial data
Seq("Alice", "Bob", "Chris") foreach { name =>
  sql"insert into members (name, created_at) values (${name}, current_timestamp)".update.apply()

// for now, retrieves all data as Map value
val entities: List[Map[String, Any]] = sql"select * from members".map(_.toMap).list.apply()

// defines entity object and extractor
import java.time._
case class Member(id: Long, name: Option[String], createdAt: ZonedDateTime)
object Member extends SQLSyntaxSupport[Member] {
  override val tableName = "members"
  def apply(rs: WrappedResultSet) = new Member(
    rs.long("id"), rs.stringOpt("name"), rs.zonedDateTime("created_at"))

// find all members
val members: List[Member] = sql"select * from members".map(rs => Member(rs)).list.apply()

// use paste mode (:paste) on the Scala REPL
val m = Member.syntax("m")
val name = "Alice"
val alice: Option[Member] = withSQL {
  select.from(Member as m).where.eq(m.name, name)
}.map(rs => Member(rs)).single.apply()

How did it go? If you'd like to know more details or see more practical examples, see the full documentation at:



Published source code and binary files have the following copyright:

Copyright scalikejdbc.org
Apache License, Version 2.0