1
votes

I'd like to do a join on two tables residing in different databases on the same MySQL server, using Slick 2.0. Usually this would just be a matter of referring to the tables via a qualified name, e.g. DB1.TABLE1.

Can someone show me how to do this in Slick?

If I don't specify a database in the JDBC connection string, I get an exception. If I do specify one of the databases there, say DB1, and specify the table name in the Table constructors as DB1.TABLE1 and DB2.TABLE2, then I get an exception about the missing table DB1.DB2.TABLE2.

1

1 Answers

1
votes

Specify any database in the connection string and pass the database as the schema argument to Table for each table class.

class SomeTable(tag: Tag) extends Table[(Int,String)](
  tag, Some("SOME_DB"), "SOME_TABLE"
) {
  def id = column[Int]("id")
  def title = column[String]("title")
  def * = (id, title)
}

This should really be documented somewhere: https://github.com/slick/slick/issues/659