我在
Scala项目中使用
slick来查询某些表.
原文链接:https://www.f2er.com/postgresql/191718.html//define table object Addresses extends Table[Address]("assetxs.address") { def id = column[Int]("id",O.PrimaryKey) def street = column[String]("street") def number = column[String]("number") def zipcode = column[String]("zipcode") def country = column[String]("country") def * = id ~ street ~ number ~ zipcode ~ country <> (Address,Address.unapply _) }
如果我使用这个表的任何查询,它不起作用(它说它找不到我的表),所以我进一步打印出如下查询:
implicit val session = Database.forURL("jdbc:postgresql://localhost:5432/postgres",driver = "org.postgresql.Driver",user="postgres",password="postgres").createSession() session.withTransaction{ val query = Query(Addresses) println("Addresses: " + query.selectStatement) }
我注意到schema.table的名字出现在“”中,所以语句是:
select x2."id",x2."street",x2."number",x2."zipcode",x2."country" from "assetxs.address" x2