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
3
votes
1 answer

How to determine required parameters from Scala API documentation?

I'm having a hard time deciphering Scala API documentation. For example, I've defined a timestamp for use in a database. def postedDate = column[Timestamp]("posted_date", O NotNull, O Default new Timestamp(Calendar.getInstance.getTimeInMillis), O…
user425367
3
votes
1 answer

How to get autoincrement ID just inserted by ScalaQuery

I am using ScalaQuery to access PostgreSql. Data is a table that has an autoincremental primarykey named id, defined as def id = column[Long] ("id", O NotNull, O PrimaryKey, O AutoInc, O DBType "serial"). I use Data.insert(name, filename) to create…
xiefei
  • 6,563
  • 2
  • 26
  • 44
3
votes
1 answer

Generic repository using ScalaQuery

I'm using the great ScalaQuery and I'm trying to create a generic repository for common operations, but I don't get along with it. Hopefully someone can help. I have for example following structure abstract class Record(id : Int) class Product(id:…
singy
  • 33
  • 3
2
votes
1 answer

Good example of using ScalaQuery in the context of Lift?

I've been using Scala for about 6 months, but just getting into the Lift framework. In the Lift docs, it is mentioned that although the default Mapper stuff is provided, one can use any ORM (or similar). Are there any good examples (uncommented…
Connor Doyle
  • 1,812
  • 14
  • 22
2
votes
1 answer

How to get a number of rows for given query?

I would like to get a number (like 5, 1000, etc.) of rows for given query. However method "count" for query gives me ColumnOps.CountAll -- and I don't know how to get the number. See SQ wiki for…
greenoldman
  • 16,895
  • 26
  • 119
  • 185
2
votes
2 answers

Working with wide SQL tables using ScalaQuery (or something else type-safe)

Many databases have tables with many columns, but ScalaQuery uses tuples to represent table schemas, and Scala doesn't support such wide tuples. Is there any way to work with such tables using ScalaQuery (short of dropping down to executing raw…
Yang
  • 16,037
  • 15
  • 100
  • 142
2
votes
1 answer

How to get class object as outcome rather than tuples in ScalaQuery?

I have started my first project in Scala and ScalaQuery. So far both are looking good and promising though I am having little difficulty once in a while. Can someone please explain me how to get a class object (in this case Domain case class having…
pawank
  • 113
  • 7
2
votes
1 answer

The elements type of for comprehension in ScalaQuery

I'm found something interesting when I following the Queries tutorial of ScalaQuery that I don't know why quite well. Here is my database schema defined: object Users extends Table[(Int, String, String)]("users") { def id = column[Int]("id", O…
Brian Hsu
  • 8,781
  • 3
  • 47
  • 59
2
votes
1 answer

How to use ScalaQuery to build a query for count(*) sql?

When I programming with the ScalaQuery, how to build a "select count(*) from table" statement? I used a Query(TestTable.count) but the generated select statement is: select count(*) from (select column1 from TestTable t2) t1 I want…
Googol Shan
  • 1,255
  • 9
  • 13
2
votes
1 answer

Unsupported length() function generated for SQLite in scalaquery

When trying to use scalaquery to retrieve the length of a text column in a SQLite database it generates the wrong SQL. I get this: SELECT "t1"."title" FROM "GoodPages" "t1" WHERE ({fn length("t1"."title")} > 65) when the query should really be…
2
votes
2 answers

different development/production databases in scalaquery

ScalaQuery requires (AFAIK) to use an provider specific import in your code, for example: import org.scalaquery.ql.extended.H2Driver.Implicit._ We are trying to use H2 in development mode and MySQL in production. Is there a way to achieve this?
Pablo Fernandez
  • 103,170
  • 56
  • 192
  • 232
2
votes
1 answer

Get auto increment key in scalaquery

I want to insert rows in 2 tables which represent a 1:n relationship using scalaquery / slick. The tables are defined as follows: object CompanyBaseTable extends Table[CompanyBaseTableEntry]("company") { def id = column[Int]("id", O PrimaryKey, O…
opeth
  • 335
  • 1
  • 5
2
votes
1 answer

MySQL driver not found with Play 2.0

I'm trying to use ScalaQuery with play 2 but I keep getting a ""no suitable driver for ...' error. The database connection works fine with Anorm/Nina. Here's my ScalaQuery code : object Client extends Table[(Int, String)]("Client") { val database =…
user1502150
  • 357
  • 1
  • 4
  • 11
2
votes
1 answer

How do I model a relational database link-table with Scala?

I need to do quite a few many to many mapping of objects in Scala and save it to a relational database. Here is a fake example to simplify the problem: Let's say we want to model lecture rooms and students. A lecture room may have many students, but…
Jack
  • 16,506
  • 19
  • 100
  • 167
2
votes
1 answer

Mapping custom types in the ScalaQuery O/R framework

In his comparison of ScalaQuery and Squeryl, Stefan Zeiger (author of ScalaQuery) says in the third bullet-point: ScalaQuery comes with support for a basic set of JDBC types and can be extended with DBMS- or application-specific types. I have…
Steve Perkins
  • 11,520
  • 19
  • 63
  • 95