Questions tagged [scalaquery]

ScalaQuery is a typesafe API / DSL (domain specific language) built on top of JDBC for accessing relational databases in Scala.

The low-level JDBC API is powerful but comes with a lot of verbosity. ScalaQuery was designed from the ground up to reduce the amount of boilerplate required and make use of Scala's features to provide a more natural fit for database access in a Scala environment.

The basic idea is that tables in the database get represented as objects extending a Table trait. This object can then be used in for comprehension extremely similar to normal Scala collection.

ScalaQuery is not an ORM, i.e. it doesn't do caching, tracking of objects for change or similar things. It is more a way to replace or generate SQL.

NOTE: Since early 2012, ScalaQuery has evolved into Slick.

99 questions
0
votes
1 answer

slick schema - fetch joined tables

doing my first steps with slick, I have this Tables case class Employee(name: String,last: String,department: Option[Int] = None,id: Option[Int] = None) class Employees (tag: Tag) extends Table[Employee](tag, "EMPLOYEES") { // Auto Increment the…
igx
  • 4,101
  • 11
  • 43
  • 88
0
votes
2 answers

Trying to do first steps with SLICK but things do not seem to work or documentation is outdated

A custom source code generator was used in order to create the classes necessary for the MySQL database as described in this question: How to setup username and password with Slick's source code generator? Then tried to follow the getting started…
George Pligoropoulos
  • 2,919
  • 3
  • 33
  • 65
0
votes
1 answer

How to reference a column by name in slick plain SQL?

I would like to use named references instead of positional in GetResult, so that instead of this: implicit val getCoffeeResult = GetResult(r => Coffee(r.<<, r.<<, r.<<)) i could write something like this: implicit val getCoffeeResult = GetResult(r…
Julio Faerman
  • 13,228
  • 9
  • 57
  • 75
0
votes
2 answers

How to use Scala's Slick sql interpolation with owner/schema name-prefixes

We have a database setup where we have a separate user for owners and users of database tables in an Oracle database. This means that in practice each query is prefixed like this: ownername.tablename This works just fine if I just write the whole…
auramo
  • 13,167
  • 13
  • 66
  • 88
0
votes
1 answer

How to parametrize Scala Slick queries by WHERE clause conditions?

Assume these two simple queries: def findById(id: Long): Option[Account] = database.withSession { implicit s: Session => val query = for (a <- Accounts if a.id === id) yield a.* query.list.headOption } def findByUID(uid: String):…
Karel Smutný
  • 1,100
  • 1
  • 9
  • 17
0
votes
1 answer

Scalaquery generating invalid sql on join onto the same table

I have a query that needs to left join onto the same table to find the latest row of an account. val all = for { Join(s,s1) <- Subscriptions leftJoin Subscriptions on ((a,b) => a.account === b.account && a.id < b.id) …
Ivan Meredith
  • 2,222
  • 14
  • 13
0
votes
1 answer

Scala Slick: Query using direct embedding doesn't work

I use the following code to request items from a mysql table (The Account class just is a case class representing the database fields) val res = Queryable[Account].map(_.name) val db = Database.forURL("jdbc:mysql://localhost:3306/databasename",…
Heinzi
  • 5,793
  • 4
  • 40
  • 69
0
votes
1 answer

Slick (Scalaquery) - insert gives type error

I am using Slick (Scalaquery) in my play framework application. According to slick tutorial - I can define a projection for columns I want to insert into. (I am defining this projection because my index is an auto-incrementing column.) But, when I…
Salil
  • 9,534
  • 9
  • 42
  • 56
0
votes
1 answer

ScalaQuery not creating DDL?

I have an example DB in a scala object, but the tables are not created. If I call the initialize and then I call the addEntries, I get a Table not existing exception by the JDBC layer. Where am I wrong? object ExampleCompanyH2TestDb { val…
Edmondo
  • 19,559
  • 13
  • 62
  • 115
1 2 3 4 5 6
7