Slick 3.0 bulk insert or update (upsert)

There are several ways that you can make this code faster (each one should be faster than the preceding ones, but it gets progressively less idiomatic-slick): Run insertOrUpdateAll instead of insertOrUpdate if on slick-pg 0.16.1+ await(run(TableQuery[FooTable].insertOrUpdateAll rows)).sum Run your DBIO events all at once, rather than waiting for each one to commit before you run … Read more

Scala Slick table tag

The best answer I’ve seen is: https://stackoverflow.com/a/27783730/154248 What’s it used for: imagine you needed to join a table on itself. That tag is a way to distinguish between the tables taking part in a query.

View SQL query in Slick

Slick 2.X: You can print the query statement as shown on the Slick documentation: val invoker = q.invoker val statement = q.selectStatement For other type of statements look at insertStatement, deleteStatement and updateStatement. Slick 3.X: val res = table.filter(_.id === 1L).result res.statements.foreach(println) Docs.

How to write database-agnostic Play application and perform first-time database initialization?

You find an example on how to use the cake pattern / dependency injection to decouple the Slick driver from the database access layer here: https://github.com/slick/slick-examples. How to decouple the Slick driver and test application with FakeApplication A few days ago I wrote a Slick integration library for play, which moves the driver dependency to … Read more

scala slick method I can not understand so far

[UPDATE] – added (yet another) explanation on for comprehensions The * method: This returns the default projection – which is how you describe: ‘all the columns (or computed values) I am usually interested’ in. Your table could have several fields; you only need a subset for your default projection. The default projection must match the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)