0
votes

I want to run a custom sql select request to my DB. Following the slick 3 docs I ended up with something like this

"com.typesafe.slick" %% "slick" % "3.0.1",
"mysql" % "mysql-connector-java" % "5.1.35",

import slick.driver.MySQLDriver.api._

val db = Database.forURL(url, username, password, driver = driver)

val s = sql"""select name, email from users""".as[(String, String)]

val f: Future[Unit] = db.run(DBIO.seq(s))

But I want to get a Seq of Tuples. How can I get it?

1

1 Answers

4
votes

From the DBIO documentation:

def seq[E <: Effect](actions: DBIOAction[_, NoStream, E]*): DBIOAction[Unit, NoStream, E]

A simpler version of sequence that takes a number of DBIOActions with any return type as varargs and returns a DBIOAction that performs the individual actions in sequence (using andThen), returning () in the end.

So, DBIO.seq will always return Unit. If you just want to execute a single query, just pass the query itself to the db.run method. Thus, you last line would be:

val f: Future[Seq[(String, String)] = db.run(s)