Questions tagged [slick]

Slick acronym for Scala Language-Integrated Connection Kit, is a modern database query and access library for Scala by Lightbend.

Slick

Slick is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can write your database queries in Scala instead of SQL, thus profiting from the static checking, compile-time safety and compositionality of Scala. Slick features an extensible query compiler which can generate code for different backends.

Slick (Scala Language-Integrated Connection Kit) is Lightbend‘s Functional Relational Mapping (FRM) library for Scala that makes it easy to work with relational databases. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can also use SQL directly. Execution of database actions is done asynchronously, making Slick a perfect fit for your reactive applications based on Play and Akka.

2469 questions
27
votes
1 answer

How to convert Rep[T] to T in slick 3.0?

I used a code, generated from slick code generator. My table has more than 22 columns, hence it uses HList It generates 1 type and 1 function: type AccountRow def AccountRow(uuid: java.util.UUID, providerid: String, email: Option[String],…
kingcw
  • 279
  • 2
  • 3
27
votes
4 answers

can't find method result on TableQuery with slick 3.0.0-RC1

I am trying out Slick 3.0.0-RC1 and I'm running in to an odd problem. Such is my code: import slick.driver.SQLiteDriver.api._ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Await import…
brujoand
  • 815
  • 8
  • 15
27
votes
1 answer

How to make aggregations with slick

I want to force slick to create queries like select max(price) from coffees where ... But slick's documentation doesn't help val q = Coffees.map(_.price) //this is query Query[Coffees.type, ...] val q1 = q.min // this is…
Jeriho
  • 7,129
  • 9
  • 41
  • 57
25
votes
1 answer

Executing non-database actions in a transaction in Slick 3

I'm having trouble understanding the new Slick DBIOAction API, which does not seem to have a lot of examples in the docs. I am using Slick 3.0.0, and I need to execute some DB actions and also some calculations with the data received from the…
Forketyfork
  • 7,416
  • 1
  • 26
  • 33
25
votes
4 answers

Insert if not exists in Slick 3.0.0

I'm trying to insert if not exists, I found this post for 1.0.1, 2.0. I found snippet using transactionally in the docs of 3.0.0 val a = (for { ns <- coffees.filter(_.name.startsWith("ESPRESSO")).map(_.name).result _ <- DBIO.seq(ns.map(n =>…
User
  • 31,811
  • 40
  • 131
  • 232
25
votes
1 answer

What is the difference between inSet and inSetBind in Slick

The ScalaDoc of the functions has not been filled out. I know that the methods are used for mimicking SQL's IN keyword (eg, SELECT * FROM table WHERE id IN VALUES(1, 42, 101) could be done with table.filter(_.id inSet Seq(1, 42, 101))). I don't know…
Mike
  • 797
  • 2
  • 9
  • 17
25
votes
2 answers

Returning AutoInc ID after Insert in Slick 2.0

I have looked to the ends of the earth for the answer to this question. There is not much info out there on slick 2.0. Below is my code for my Addresses model, how would I have the method create return the id after it made the insert? package…
James Little
  • 601
  • 7
  • 24
25
votes
4 answers

How to persist enum value in slick

I have the follow enum: object LoginStatus extends Enumeration() with BitmaskedEnumeration { type LoginStatus = Value val Active = Value("A") val Inactive = Value("I") } I need to persist the value of the enum "A", but when the sql is…
Diogo
  • 543
  • 6
  • 12
23
votes
6 answers

Scala Slick, how to create Schema ONLY if it does not exist

In Scala Slick, a database schema can be created with the following: val schema = coffees.schema ++ suppliers.schema db.run(DBIO.seq( schema.create )) From the bottom of this documentation page…
Phil
  • 46,436
  • 33
  • 110
  • 175
23
votes
2 answers

How to run ScalaTest with Guice DI and Slick?

I don't know how to configure GuiceApplicationBuilder in such a way, that I am able to load controllers that require a DatabaseConfigProvider to be injected. I'd like to specify an alternative postgres database for testing, or an in memory database…
Taig
  • 6,718
  • 4
  • 44
  • 65
22
votes
1 answer

Slick confused about numThreads and best practice for good performance

I am using the PlayFrameWork with Slick and using it in a system that is all I/O database heavy. In my application.conf file I have this setting: play { akka { akka.loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = WARNING actor { …
user1591668
  • 2,591
  • 5
  • 41
  • 84
21
votes
3 answers

What does the <> operator do in Slick?

I was walking through the documentation of Slick to setup a quick working prototype. In the Mapped Tables section I see a <> operator in the example mentioned but can't find any documentation for that anywhere. Need help in understanding this.
Som Bhattacharyya
  • 3,972
  • 35
  • 54
21
votes
2 answers

How can I handle a > 22 column table with Slick using nested tuples or HLists?

I'm new to Scala (using 2.10) and Slick (using 2.0-M2). I see that one of the ways to get around the 22 column limit for tables in Slick is to use nested tuples. I can't figure out how to do that, despite finding this partial code on GitHub. …
sventechie
  • 1,859
  • 1
  • 22
  • 51
21
votes
2 answers

multiple joins with slick

For joining between two tables is done like (for { (computer, company) <- Computers leftJoin Companies on (_.companyId === _.id) if computer.name.toLowerCase like filter.toLowerCase() } But in case if joining required between more…
dsr301
  • 759
  • 3
  • 7
  • 21
21
votes
5 answers

Is it possible to use IN clause in plain sql Slick?

For example, I want to create the following query: SELECT c.* FROM Coffees c WHERE c.name IN ('robusta', 'arabica') My attempt failed: val cnames = List("robusta", "arabica") sql""" SELECT c.* FROM Coffees c WHERE c.name IN ${cnames} """ could…
Rogach
  • 26,050
  • 21
  • 93
  • 172