Databases

play.api.db.Databases
object Databases

Creation helpers for manually instantiating databases.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Databases.type

Members list

Value members

Concrete methods

def apply(driver: String, url: String, name: String, config: Map[String, _]): Database

Create a pooled database named "default" with the given driver and url.

Create a pooled database named "default" with the given driver and url.

Value parameters

config

a map of extra database configuration

driver

the database driver class

name

the database name

url

the database url

Attributes

Returns

a configured database

def inMemory(name: String, urlOptions: Map[String, String], config: Map[String, _]): Database

Create an in-memory H2 database.

Create an in-memory H2 database.

Value parameters

config

a map of extra database configuration

name

the database name (defaults to "default")

urlOptions

a map of extra url options

Attributes

Returns

a configured in-memory h2 database

def withDatabase[T](driver: String, url: String, name: String, config: Map[String, _])(block: Database => T): T

Run the given block with a database, cleaning up afterwards.

Run the given block with a database, cleaning up afterwards.

Value parameters

block

The block of code to run

config

a map of extra database configuration

driver

the database driver class

name

the database name

url

the database url

Attributes

Returns

The result of the block

def withInMemory[T](name: String, urlOptions: Map[String, String], config: Map[String, _])(block: Database => T): T

Run the given block with an in-memory h2 database, cleaning up afterwards.

Run the given block with an in-memory h2 database, cleaning up afterwards.

Value parameters

block

The block of code to run

config

a map of extra database configuration

name

the database name (defaults to "default")

urlOptions

a map of extra url options

Attributes

Returns

The result of the block