我正在尝试ScalaQuery,它真的很棒。我可以使用Scala类定义数据库表,并轻松查询。我怎么能知道ScalaQuery中是否存在数据库表格
但我想知道,在下面的代码中,如何检查一个表是否存在,所以我不会调用两次“Table.ddl.create”并在运行此程序时得到一个异常?
object Users extends Table[(Int, String, String)]("Users") {
def id = column[Int]("id")
def first = column[String]("first")
def last = column[String]("last")
def * = id ~ first ~ last
}
object Main
{
val database = Database.forURL("jdbc:sqlite:sample.db", driver = "org.sqlite.JDBC")
def main(args: Array[String]) {
database withSession {
// How could I know table Users is alrady in the DB?
if (???) {
Users.ddl.create
}
}
}
}
感谢这篇文章!这是在游戏中制作异步引导的好方法!框架(http://www.playframework.org/documentation/1.2.4/jobs)。干杯, – egbutter 2012-01-29 16:36:09