Questions tagged [slick]

Slick acronym for Scala Language-Integrated Connection Kit, is a modern database query and access library for Scala by Lightbend.

Filter by
Sorted by
Tagged with
0 votes
1 answer
31 views

Parameter Binding or String Interpolation for Building SQL Plain Queries in Scala?

def insertToTableSQLQuery(tableName: String, columnDefinitions: Seq[ColumnDefinition], rowData: ListBuffer[Any]): Future[Int] = db.run { val columns = columnDefinitions.map(_.name).mkString(&...
SM-171's user avatar
  • 1
0 votes
1 answer
69 views

Slick doesn't run Evolutions with Play Framework

I have an app that was using scala.play with a jdbc connection to a postgresql database and play evolutions and I have been trying to migrate to using slick, to reduce the amount of boilerplate in ...
Arthur's user avatar
  • 3,378
1 vote
0 answers
66 views

Trait for composite primary keys in Slick tables?

I have 2 tables case class SimplePKDB(id: Long = 0L) object SimplePKDB { final class SimplePKTable(tag: Tag) extends Table[SimplePKDB](tag, "simple_table") { def id: Rep[Long] = ...
Максим Дерюгин's user avatar
0 votes
0 answers
56 views

How to do sql queries with intersect with Slick?

I am trying to build sql queries with slick where I need to intersect the results. I can build it with union (from Slick docs): val q1 = coffees.filter(_.price < 8.0) val q2 = coffees.filter(_....
Guillem I's user avatar
1 vote
1 answer
36 views

Fit image to screen using CSS with Slick Carousel

I am making an image carousel using Slick. I want to fit the width of the image along screen and the height is scaled with the width. Below is my index.html: <!DOCTYPE html> <html> <...
Becker's user avatar
  • 159
0 votes
0 answers
31 views

Scala play slick postgresql

I am trying to get the hang of slick and have a simple client to save and load users import play.api.db.slick.DatabaseConfigProvider import com.github.tminglei.slickpg._ import ...
Arthur's user avatar
  • 3,378
0 votes
1 answer
43 views

Scala, Slick, Cats - How to map different SQL errors with OptionT?

I have a simple slick query which run on database: def method(): Future[Either[Error, MyCustomDTO]] = OptionT(database.run(query)) .map(MyCustomDTO(_)) .toRight(dataNotFound()) .value The ...
Developus's user avatar
  • 1,412
0 votes
0 answers
29 views

slick 3.3.3, oracle 11g, scala

I want to use slick.jdbc.OracleProfile to support the autoincremention of primary key with oracle 11g. I use slick version 3.3.3. I've noticed that in slick.jdbc.OracleProfile there is method that ...
Im89's user avatar
  • 139
0 votes
1 answer
31 views

Slick 3.3.3 not parsing mysql datetime

Im using slick 3.3.3, and i have a table with columns setup with LocalDateTime (ive also tried OffsetDateTime) I was told slick 3.3.3 fixes the issue but no matter what I do i still get Text '2023-09-...
Mr. MonoChrome's user avatar
0 votes
1 answer
71 views

How to get play datasource instance when using slick

I am using play-slick with slick evolutions to create my db. I have the following config slick.dbs.default.profile="slick.jdbc.H2Profile$" slick.dbs.default.db.driver="org.h2.Driver&...
user3408657's user avatar
0 votes
1 answer
56 views

Scala Plain query not giving the desired Result set

I tried to bring the data after retriving from the database but it isnt retriving the data as i need how to map the data so that i can get it in the required format This is my repository package ...
Vedansh Trivedi's user avatar
0 votes
0 answers
80 views

Array aggregate subquery with Slick-pg for postgres

I am trying to use an aggregate function from slick-pg in a query with subquery but I am getting an Exception slick.SlickException, with message: No type for symbol s5 found for Ref s5.. This is the ...
Benjamin Maurer's user avatar
0 votes
0 answers
31 views

Does slick support NULLS NOT DISTINCT in table definitions

Is it possible to define such index using slick table definitions: ALTER TABLE user_group ADD CONSTRAINT unique_constraint UNIQUE NULLS NOT DISTINCT (age_group_id, location_id); https://www....
senjin.hajrulahovic's user avatar
0 votes
0 answers
27 views

How to get values bound to a FixedSqlAction in Slick for unit test assertions?

I'd like to write better unit tests for Slick queries by testing that the correct values are bound in the right place. Here's a simplified example of the type of method I'd like to test: def ...
Matthew's user avatar
  • 6,431
0 votes
0 answers
47 views

How to provide custom filter in Slick

I have a lot of database tables. All those tables have some common columns. I want to use Slick to filter and union those tables and return only the common columns. The uncommon columns are dynamic. ...
Rohan's user avatar
  • 1
0 votes
0 answers
22 views

I'm discovering Slick . I am trying to do a simillar query in slick but I got an error in minusDays(user_config)) with user_config being Rep[Long]

select * from Users JOIN field f on users.id = f.id JOIN user_config uconf on users.id_config = uconf.id where users.updated_at < CURRENT_DATE - (uconf.delay_days || ...
Nasry's user avatar
  • 1
0 votes
1 answer
41 views

Type missmatch on Slick TableQuery

I am trying to have a generic type definition that can be satisfied by slicks TableQuery type: class OrderTable(tag: Tag) extends Table[Order](tag, "orders") ... val orders = ...
Georg Prohaska's user avatar
0 votes
0 answers
34 views

Profiles in Slick and DAO classes

I'm learning Slick from the official site: https://scala-slick.org. Under "Resources" they put a link to underscore.io which is really great, "Essential Slick" is a very nice guide ...
M.G.'s user avatar
  • 369
2 votes
1 answer
54 views

Can I parameterize a Slick query macro?

In Slick, one can write a query in a macro, and it is transformed in a pretty good query, with a type, e.g. like this: db.run(sql"""SELECT COUNT(1) FROM myTable""") But ...
Vlad Patryshev's user avatar
0 votes
0 answers
37 views

How to conditionally sum/count with Slick, Scala, Postgres

I'm trying to slick to generate an SQL for postgres that is similar to: SELECT ..., SUM(b.charge_amount) filter ( where b.status like 'ACCEPTED%') FROM bills I have the following scala code ...
aclowkay's user avatar
  • 3,607
0 votes
0 answers
93 views

Insert or update scala dataframe in postgres

I have a look up table that needs to be updated from my spark code. There are multiple spark jobs using the same look up table. I have a dataframe that needs to be inserted or updated into Postgres ...
mythic's user avatar
  • 555
1 vote
0 answers
26 views

Scala slick primary key skipped when using .transactionally

I have a route with path("employee") that does simple POST and path("transaction") what it does is it tries to add data twice to the db. But i fail it by entering a column data ...
Always_a_learner's user avatar
0 votes
0 answers
36 views

when to use direct sql query vs type-safe slick

I am not sure when slick runs the sql query and returns the result set. I want to run different queries but my table is very big. The sql command it self takes few seconds to run. I am afraid if I use ...
Marjan M's user avatar
0 votes
1 answer
126 views

How to return object with scala slick after insert

I'm trying to use generic insert function that would return object when inserting data using Slick. I've tried with following code // This works without any issues but limited to specific ...
Sujit Baniya's user avatar
0 votes
2 answers
77 views

Slick Futures converted into Promises

I am starting to develop in Scala, so I started witha really simple RESTful API using AKKA HTTP actors and then wanted to add a PostgreSQL database to "close up" the project. The thing is ...
Drethtar's user avatar
0 votes
0 answers
29 views

Create a virtual column in Slick that is a combination of two?

Say I have a table names like so: id | first_name | last_name =========================== 1 | Cory | 2 | | Smith 3 | Rebecca | Random And its corresponding Slick model looks ...
Cory Klein's user avatar
  • 52.1k
0 votes
0 answers
52 views

Slick 3.4.1 + Scala Driver org.h2.Driver does not know how to handle URL jdbc:mysql://localhost:3306/Test

I am using Slick 3.4.1 and Scala 2.12 and this is my code to connect to a MySql Database: while this is mySql workbecnh It seems like the Sql is not running though, seen that when I try ping 127.0.0....
StoCa_overflow's user avatar
0 votes
0 answers
36 views

Conversion of plain PostgreSQL query to Slick query

I have a single table ABC with these (relevant) columns create table abc ( transaction_id uuid not null, store_items jsonb ...
Aye Alk's user avatar
0 votes
1 answer
137 views

Custom LocalDateTime parser in Slick 3

I'm converting a bunch of java.sql.Timestamp columns from my Slick 3 models into LocalDateTime. My database backend is MySQL 8 and the columns I'm converting are either TIMESTAMP or DATETIME. I ran ...
Christoffer's user avatar
  • 25.4k
0 votes
1 answer
72 views

what is the connection string using alwaysdata with scala

i am using Scala with play and slick. scalaVersion := "2.13.10" libraryDependencies += guice libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" %...
user609511's user avatar
  • 4,131
1 vote
0 answers
96 views

Scala: value returning is not a member of slick.lifted.TableQuery

I`m trying to write an API using Slick (3.4.1) and Akka-Http, and i encountered a problem with database inserts. Table in question looks like this: class Orders(tag: Tag) extends Table[(Int,Int,...
Ni3dzwi3dz's user avatar
-1 votes
1 answer
55 views

Why does my code not return query results?

Creating the database works. SQLite editor returns correct values. Yet, running below code does not return results. I added println("completed") to verify this part of code is reached: val ...
Ni3dzwi3dz's user avatar
2 votes
1 answer
218 views

`Scala Slick` org.postgresql.util.PSQLException: ERROR: relation "movies.Movie" does not exist

Calling demoInsertMovie() from Main I get back nothing from the future. After waiting for the Future to complete, case Failure is executed with org.postgresql.util.PSQLException: ERROR: relation "...
Always_a_learner's user avatar
0 votes
1 answer
134 views

Slick update tuple with more than 22 elements

I'm running a Scala Play project where Slick is used for the database. I've now added a new field to the Books table in the database and when I try to update an item like I used to do before I get the ...
gusjap's user avatar
  • 2,415
0 votes
1 answer
118 views

DBIOAction[_, NoStream, Read with Write with Read] in Slick

Let's say I have the following action which does at first a read operation and then updates the fields. action1: DBIOAction[Any, NoStream, Read with Write] Let action2 do another read operation on ...
heuristic123's user avatar
0 votes
1 answer
189 views

Batch inserts and LAST_INSERT_ID with Slick and MariaDB

I'm trying to insert some data into a MariaDB database. I got two tables and I have to insert the rows (using a batch insert) into the first table and use the IDs of the newly-inserted rows to perform ...
madipi's user avatar
  • 345
0 votes
1 answer
2k views

h2 named database schema not found

when I create h2 memory database with a "name", I can't seem to use the name to refer to the table and keep getting "schema not found". Any idea? val con = DriverManager....
baron's user avatar
  • 169
0 votes
1 answer
27 views

How to change many fields at the same time in Slick update query?

Lets say I have a table for movies which has many fields such as id, the name of the movie,year it was created etc. I know that the following works: val updateMovieNameQuery = SlickTables.movieTable....
heuristic123's user avatar
0 votes
1 answer
293 views

slick Database configuration/initialization not working using Database.forConfig(path)

I want to use pooled database connections, by using HikaryCP. So I got in my dependencies: "com.typesafe.slick" %% "slick" % Version.slick "com.typesafe.slick" %% "...
Frank Endriss's user avatar
1 vote
1 answer
132 views

How to run multiple plain sql queries ― multiple times ― in a single transaction in slick?

I have a Play/Slick application where I need to run several plain sql queries multiple times (n) in a single transaction. Here is the code for one iteration, i.e. when n = 1: val query1 = sql"&...
rapt's user avatar
  • 11.9k
0 votes
0 answers
183 views

Scala on Intellij: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use

reference of code: Populate H2 in-mem db from .csv file using scala slick I want to insert id,timestamp, and social_media from csv to mysql. But there's an Error on my SQL syntax, I don't understand ...
mirsyadsbk's user avatar
0 votes
1 answer
255 views

class defined in trait cannot be serialized

I tried to cache some objects in binaries these days. But when I try to serialize my case classes defined in a trait, exception happens as bellow: Exception in thread "main" java.io....
crowhite's user avatar
1 vote
1 answer
282 views

Using plain SQL query with LIKE operator and % wildcards in Slick

I am trying to use a plain SQL query in Slick. The query has a LIKE operator with % wildcards. val someText: String = "some text" val query = sql"""SELECT mt.id, mt.name ...
rapt's user avatar
  • 11.9k
0 votes
1 answer
232 views

How to increment a column in Slick if it exists otherwise insert it with a default value?

This is my sample case class: package com.test.models.sample case class UserVisitFO( id: Long = 0L, userId: Long, ...
Alireza's user avatar
  • 6,581
1 vote
1 answer
96 views

DBIOAction cleanUp or asTry do not lead to internal execution

I'm trying to test whether side effects get executed or not. Neither DBIOAction.successful(()).cleanUp(_.fold { println("yeay!") DBIOAction.successful(()) } { _ => println("...
juanchito's user avatar
  • 490
0 votes
0 answers
149 views

Return ids after upsert Slick

I have a query that upserts the data to the database via Slick. I'd like to return the ids of the entities that were inserted. How can I do this using Slick in Scala. Here's a current query and entity ...
Cassie's user avatar
  • 2,991
1 vote
1 answer
296 views

How to fix the No implementation for play.api.db.DBApi was bound. with play 2.8.13

we are upgrading the tech stack versions of my project due to log4j vulnerability. SBT 1.6.2, Scala 2.13.6, play_scala 2.8.13 I used below dependencies to connect database and I mentioned db ...
newbie's user avatar
  • 456
0 votes
1 answer
27 views

Print out all the data within a TableQuery[Restaurants]

def displayTable(table: TableQuery[Restaurants]): Unit = { val tablequery = table.map(_.id) val action = tablequery.result val result = db.run(action) result.foreach(id => id....
Major_Adeen's user avatar
0 votes
1 answer
105 views

How to avoid a nested query?

In Sangria I'm getting a list of users by IDs lazy val UsersType: ObjectType[GraphQLContext, Seq[User]] = ObjectType("users", () => fields[GraphQLContext, Seq[User]]( Field("...
Marat's user avatar
  • 39
0 votes
1 answer
40 views

Am I able to use normal plain java class with Slick?

I know we can use a case class as the type parameter of the Slick Table defination like this: case class User(id:Option[Int], name:Option[String]) class TestUserTable(tag: Tag) extends Table[User](...
user3593261's user avatar

1
2 3 4 5
50