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
1
vote
1 answer

How can I JOIN tables in different databases (on the same server) using Slick?

I'd like to do a join on two tables residing in different databases on the same MySQL server, using Slick 2.0. Usually this would just be a matter of referring to the tables via a qualified name, e.g. DB1.TABLE1. Can someone show me how to do this…
Scott Morrison
  • 3,100
  • 24
  • 39
1
vote
1 answer

Slick 2.0: Cannot insert java.sql.Timestamp into a table using HList

I'm getting a class cast exception in this script and I simply cannot get why. The error is: java.lang.ClassCastException: java.sql.Timestamp cannot be cast to scala.Product here's my code: import java.sql.Timestamp import…
Max
  • 2,508
  • 3
  • 26
  • 44
1
vote
1 answer

compare 2 dates in a slick query seems hard

helllo I can't adapt this example of code : https://github.com/pedrofurla/slick-demo/blob/master/src/main/scala/slickdemo/domain/Person.scala. it deals with the capacity of comparing dates in a slick query. The difficulty is you can't access to the…
lolveley
  • 1,659
  • 2
  • 18
  • 34
1
vote
1 answer

How to get inserted object back (with default values from database)?

I'm curious how I get the inserted object back. I'd like to return the constructed model object in my create API route in Play. So far I have something like: def create(username: String, email: String, password:String)(implicit database: Database):…
Setheron
  • 3,520
  • 3
  • 34
  • 52
1
vote
2 answers

How to create tables given a Seq[TableQuery] in Typesafe's Slick?

I'm running into problems when trying to populate a DB with tables (using Slick 2.0.0): import scala.slick.driver.JdbcDriver import scala.slick.lifted.TableQuery case class DemoInit(slickDriver:JdbcDriver, tables:Seq[TableQuery[_]]) { lazy val db…
Andrey
  • 8,882
  • 10
  • 58
  • 82
1
vote
0 answers

Slick Lifted API generating invalid syntax sql query

I've been trying to add Slick to my app, and everything has been going great until I had to do a left join. Below is the sql query that I'm trying to generate: SELECT i.id,i.category_id,iab.aspect_ids FROM items i LEFT JOIN item_aspects_binary iab…
T_Rex
  • 43
  • 4
1
vote
0 answers

How to define a general get() method in Slick DAO

I'm used to write SQL or use simple database interaction tool like Active Record. Slick has this really elaborate functional database connection concept, and I want to learn more, although just beginning. I used play-slick and some people told me to…
windweller
  • 2,365
  • 5
  • 33
  • 56
1
vote
1 answer

Scala, Slick connect to MSSQL server

I am trying to connect to a MSSQL database using the slick framework. The following code shows my first attempt but I can't figure out what is wrong. This error occurs when leaving it as shown below: [1] value create is not a member of…
Coxer
  • 1,694
  • 2
  • 26
  • 44
1
vote
1 answer

Slick projection operator/method documentation in scaladocs

I extracted the following snippet from a Slick table definition: object Person extends Table[(String, String, Int)]("person"){ ... def firstName = column[Long]("firstName") ... def * = firstName ~ lastName ~ age } My question is: where is…
balteo
  • 23,602
  • 63
  • 219
  • 412
1
vote
2 answers

Scala Slick 2.0 with PostgreSQL. Compare Timestamp

I'm using Slick 2.0.0-RC1 with PostgreSQL. How I can compare Timestamp column when I create select query. Suppose I'm trying to make simple query and fetch events with start date after now. I have column in my table: val start:…
selfsx
  • 581
  • 7
  • 23
1
vote
0 answers

Group by with projections for Query resulting more than 22 columns in Slick

Please consider following scenario 1) Table 1 contains 16 columns 2) Table 2 contains 18 columns I need to select all the columns from these tables and since total number of columns (34) is more than 22(constraints on tuple fields), I am using…
Mkt281001
  • 275
  • 1
  • 14
1
vote
1 answer

why does the slick can not store Option[String]?

I use slick 2.0 rc1 in my playframework 2.2 project my talbe code is: case class Resource(id: Option[Long] = None, owner: UserId, types: String) // The static object that does the actual work - note the names of tables and fields in H2 are case…
user504909
  • 9,119
  • 12
  • 60
  • 109
1
vote
1 answer

The "~:" is what meaning in slick and why the DateTime did not recognize

I use slick and playframework 2.1 why "~" is not recognize as operator, why? object Comments extends IdTable[CommentId, Comment]("COMMENTS") { def text = column[String]("TEXT") // you can use your type-safe ID here - it will be mapped to long in…
user504909
  • 9,119
  • 12
  • 60
  • 109
1
vote
1 answer

how to make Option[Int] save in scala slick

I want to save Rescource with foreignkey of Users case class User(id: Option[Int], name : String) object Users extends Table[User]("users") { def id = column[Int]("id", O.PrimaryKey) def name = column[String]("name", O.NotNull) def * = id.? ~ name…
user504909
  • 9,119
  • 12
  • 60
  • 109
1
vote
1 answer

How to use transactions in a controller in Scala

I am trying to write into multiple tables in my controller. And i want all those rows to be transactional in nature. I can put them in slick withTransaction block, but this is business logic and I don't want to put it in database layer. Also, if one…
Karthik
  • 97
  • 2
  • 8
1 2 3
99
100