BAR
BAR

Reputation: 17111

Is Slick Missing the Database Class?

I cannot find Slick's Database class. It is referenced in all their guides.

http://slick.typesafe.com/doc/2.1.0/gettingstarted.html

Database.forURL("jdbc:h2:mem:test1", driver = "org.h2.Driver") withSession {
  implicit session =>
  // <- write queries here
}

Seems to be missing from the API docs as well.

http://slick.typesafe.com/doc/2.1.0/api/#package

Upvotes: 2

Views: 235

Answers (1)

Dylan
Dylan

Reputation: 13924

Database is actually something you import from the appropriate driver class. In the guides, they start with this:

// Use H2Driver to connect to an H2 database
import scala.slick.driver.H2Driver.simple._

H2Driver is a JdbcDriver, which defines a whole lot of types. To simplify the import process, JdbcDriver defines a SimpleQL trait (of which H2Driver.simple is an instance). In that trait, you'll find val Database, which is actually a DatabaseFactory.

link: SimpleQL in the docs

Upvotes: 3

Related Questions