play-slick

Create table from slick table definition

冷暖自知 提交于 2021-01-28 05:24:33
问题 In PlaySlick sample there is file with sample data access object. https://github.com/playframework/play-slick/blob/master/samples/basic/app/dao/CatDAO.scala and table definition: private class CatsTable(tag: Tag) extends Table[Cat](tag, "CAT") { def name = column[String]("NAME", O.PrimaryKey) def color = column[String]("COLOR") def * = (name, color) <> (Cat.tupled, Cat.unapply) } Is it possible to generate a new table using this definition without using play evolutions? If not, why? 回答1:

Play slick session connection timeout

試著忘記壹切 提交于 2020-01-05 09:05:40
问题 I'm having a problem with the session and connection handling in play with Slick 2.0.1 and play-slick 0.6.0.1 The error is [SQLException: Timed out waiting for a free available connection.] [...] Caused by: java.sql.SQLException: Timed out waiting for a free available connection. at com.jolbox.bonecp.DefaultConnectionStrategy.getConnectionInternal(DefaultConnectionStrategy.java:88) ~[bonecp.jar:na] [...] I have a play base controller trait for setting up the explicit session in one place

Assign dynamically injected database name in Play Slick

◇◆丶佛笑我妖孽 提交于 2019-12-24 05:35:08
问题 I have the following Play Slick DAO class. Note that the database configuration is a constant control0001 . The DAO has a function readUser that reads a user based on its user id: class UsersDAO @Inject()(@NamedDatabase("control0001") protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider[JdbcProfile] { import driver.api._ def readUser (userid: String) = { val users = TableQuery[UserDB] val action = users.filter(_.userid === userid).result val future = db

Cache Slick DBIO Actions

こ雲淡風輕ζ 提交于 2019-12-22 11:37:18
问题 I am trying to speed up "SELECT * FROM WHERE name=?" kind of queries in Play! + Scala app. I am using Play 2.4 + Scala 2.11 + play-slick-1.1.1 package. This package uses Slick-3.1 version. My hypothesis was that slick generates Prepared statements from DBIO actions and they get executed. So I tried to cache them buy turning on flag cachePrepStmts=true However I still see "Preparing statement..." messages in the log which means that PS are not getting cached! How should one instructs slick to

How to use a Non Supported Database in Slick 3.1

孤街醉人 提交于 2019-12-22 05:15:21
问题 In the past I have used Slick to access a Vertica database in a server. I recently upgraded my version of Slick from 2.0 to 3.1. Since the upgrade, I am encountering an error (stack trace below). The error indicates that the slick driver cannot be found. According to the Slick 3.2.1 docs, "Other SQL databases can be accessed right away with a reduced feature set". What I am wondering is - Is it still possible to use an "Other" type of database from those directly supported by slick? If so,

Compiled Querys in Slick

我怕爱的太早我们不能终老 提交于 2019-12-12 17:23:18
问题 I need to compile a query in Slick with Play and PostgreSQL val bioMaterialTypes: TableQuery[Tables.BioMaterialType] = Tables.BioMaterialType def getAllBmts() = for{ bmt <- bioMaterialTypes } yield bmt val queryCompiled = Compiled(getAllBmts _) but in Scala IDE I get this error in the Apply of Compiled Multiple markers at this line - Computation of type () => scala.slick.lifted.Query[models.Tables.BioMaterialType,models.Tables.BioMaterialTypeRow,Seq] cannot be compiled (as type C) - not

Play-slick with SecureSocial: Running DB IO in a separate thread pool

落爺英雄遲暮 提交于 2019-12-12 07:53:33
问题 I have a Play 2.2.1 app that uses play-slick 0.5.0.8 to persist data to a Postgresql backend and SecureSocial 2.1.2 to handle user authorisation. Since play-slick transactions are blocking, I have created a separate slick-context execution context in my /conf/application.conf file, as per the instructions found in the plugin's Wiki: play { akka { actor { slick-context = { fork-join-executor { parallelism-min = 300 parallelism-max = 300 } } } } } This allows me to create a controller Action

Where to put my database access methods when using a DAO with Slick 2.0?

拟墨画扇 提交于 2019-12-11 10:24:48
问题 (This question is based on a very similar previous request for help. With the introduction of a DAO and multiple database drivers, the same problem requires a different approach, and I hope warrants a new SO question.) I have a class and Slick Table defined like this: import play.api.db.slick.Profile case class Foo(title: String, description: String, id: Int = 0) trait FooComponent extends Profile { this: Profile => import profile.simple._ class FooTable(tag: Tag) extends Table[Foo](tag, "FOO

Can't access delete method on Slick query

只愿长相守 提交于 2019-12-10 18:15:06
问题 This is very very very frustrating. I have been trying to pick up Slick for a while, and obstacles just keep coming. The concept of Slick is really awesome, but it is very difficult to learn, and unlike Scala, it doesn't have "beginner", "intermediate", and "advanced" style where people in all stages can use it easily. I'm using Play-Slick (Slick 2.0.0) https://github.com/freekh/play-slick, following its Multi-DB cake example: https://github.com/freekh/play-slick/tree/master/samples/play

(Play 2.4.2, Play Slick 1.0.0) How do I apply database Evolutions to a Slick managed database within a test?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 16:47:28
问题 I would like to write database integration tests against a Play Slick managed database and apply and unapply Evolutions using the helper methods described in the Play documentation namely, Evolutions.applyEvolutions(database) and Evolutions.cleanupEvolutions(database) . However these require a play.api.db.Database instance which is not possible to get hold of from what I can see. The jdbc library conflicts with play-slick so how do I get the database instance from slick? I use the following