在Slick 2.1中,我有以下代码从文件中执行sql-query:
def fetchResult[T](sql: String)(implicit getResult: GetResult[T]): List[T] = {
val query = Q.queryNA[T](sql)
try {
Database.forDataSource(DB.getDataSource())
.withSession { implicit session => query.list }
}
catch {
case e: Throwable =>
throw new RunSqlException(s"Query $name execution error", e)
}
}
在Slick 3.0.0中,您使用dbConfig.db.run方法执行DBIOAction并获得结果的未来。但我找不到将Q.queryNA(StaticQuery[Unit, R]
)的结果转换为DBIOAction
的方法。这种方式存在吗?
我现在结束了不赞成的电话。帮助我变得更好!
def fetchResult[T](sql: String)(implicit getResult: GetResult[T]): Future[List[T]] = Future {
val query = Q.queryNA[T](sql)
try {
this.dbConfig.db.withSession { implicit session => query.list }
}
catch {
case e: Throwable =>
throw new RunSqlException(s"Query $name execution error", e)
}
}
答案 0 :(得分:6)
我设法找到的解决方案只是有点hackish:
.section{
background-color: rgba(0, 0, 0, 0.3);
display: inline-block;
padding: 20px;
margin-right: 30px;
margin-bottom: 30px;
max-width: 300px;
height: 400px;
}