slick-3.0

SLICK 3.0 - multiple queries depending on one another - db.run(action)

守給你的承諾、 提交于 2021-02-07 05:29:05
问题 I am new to Slick 3 and so far I have understood that db.run are asynchronous call. the .map or .flatMap is run once the Future is returned. The problem in my code below is that all the sub queries do not work (nested db.run). Conceptually speaking, what am I not getting? Is it valid to do this kind of code as below? basically in the .map of the first query I do some actions depending on the first query. I see everywhere for loops with yield , is it the only way to go? Is the problem in my

Slick 3.1, Left Joins and Filters

别说谁变了你拦得住时间么 提交于 2021-01-23 06:33:33
问题 I have a Slick query with two left joins (which end up as a Rep[Option[...]] ) and column maps. I need to filter (using like ) on the results. A row has to be included in the results if any of three columns match the like criteria, so I can't pre-filter the tables - I have to filter the resulting join, Rep[Option] s and all. I can't figure how to filter the Rep[Option[String]] columns. The below code does not compile due to "cannot resolve symbol ||" - if compiles perfectly when I remove the

Spark Structured Streaming Multiple WriteStreams to Same Sink

岁酱吖の 提交于 2020-12-29 13:55:40
问题 Two Writestream to the same database sink is not happening in sequence in Spark Structured Streaming 2.2.1. Please suggest how to make them execute in sequence. val deleteSink = ds1.writestream .outputMode("update") .foreach(mydbsink) .start() val UpsertSink = ds2.writestream .outputMode("update") .foreach(mydbsink) .start() deleteSink.awaitTermination() UpsertSink.awaitTermination() Using the above code, deleteSink is executed after UpsertSink . 回答1: If you want to have two streams running

How to write readable nested join queries with Slick 3.0

你说的曾经没有我的故事 提交于 2020-01-14 10:45:27
问题 This code is creating a query for use in retrieving a user's profile on a web back end. It creates a query that assembles the necessary information into a DTO (which is just a case class) that is subsequently sent back as JSON. def getProfile(userId: Long)={ val q = for{ ((((u,p),a),b), ba) <- filterById(userId) join People on (_.personId === _.id) joinLeft Addresses on (_._2.addressId === _.id) joinLeft Businesses on (_._1._2.businessId === _.id) joinLeft Addresses on (_._2.flatMap(_

Scala+Slick 3: Inserting the result of one query into another table

ⅰ亾dé卋堺 提交于 2020-01-14 07:50:11
问题 This question is about slick 3.0 or 3.1 (I am flexible about that) I have an intermediate query which I process with map , for , etc. to obtain the result I want. In the end I have a val foo: DBIOAction[Seq[MySchema.Bar], NoStream, Effect.Read] Now I have a val bar: TableQuery[MySchema.Bar] and I want to insert foo in to it. If foo would be a Seq I could simply do bar ++= foo , but it is not. The only way I found is to materialize the result by awaiting it. Like this val query = (bar ++=

Scala Slick and nested case classes

旧街凉风 提交于 2020-01-14 04:21:07
问题 I'm quite new to Scala and need to use slick to build a table mapping for these case classes. I can do it for a simple case class but the nesting and option parameters are leaving me confused how to do this? case class Info(fullName: Option[String], dn: Option[String], manager: Option[String], title: Option[String], group: Option[String], sid: Option[String]) case class User(username: String, RiskScore: Float, averageRiskScore: Float, lastSessionId: String, lastActivityTime: Long, info: Info)

Connecting to Mysql using Slick 3.0 - No username, no password and bogus driver does not equal error

房东的猫 提交于 2020-01-14 03:48:39
问题 I'm writing a veery simple scala script to connect to Mysql using slick 3. My build.sbt looks like this: name := "slick_sandbox" version := "1.0" scalaVersion := "2.11.7" libraryDependencies ++= Seq( "com.typesafe.slick" %% "slick" % "3.0.3", "org.slf4j" % "slf4j-nop" % "1.6.4", "mysql" % "mysql-connector-java" % "5.1.6" ) application.conf : Drivder is an intentional mistake; also, I did not provide a db username or password! mysqldb = { url = "jdbc:mysql://localhost/slickdb" driver = com