问题
Slick is returning result in DML queries, throwing exceptions while executing table creation actions, but the MTable.getTables return empty vector/list. I am using MySQL as SQL solution.
println(Await.result(db.run(MTable.getTables), Duration.Inf))
Prints Vector()
in console.
回答1:
Honestly have the same issue, wen't through a ton of posts and ideas what could be wrong and nothing worked, don't want to waste time on it so the easy way around it is to just have something like using sql directly:
db.run(sql"""show tables""".as[String]).onComplete({
case scala.util.Success(value) => value.foreach(println)})
Which would return something like: city country countrylanguage I'm sure you could work it out how to use it from there.
p.s sorry for poor code example formatting
回答2:
The problem in my first case was invalid table structure.
The problem in my second case was invalid write permissions.
How to know the exact problem behind query failure:
Do this:
val tables = List(Emails.emails)
val setup = DBIO.sequence(
tables.map(_.schema.create.asTry)
)
Await.result(db.run(setup).map(a => {
println("/****\n\n\n\n\n\n\n\n\n\n\n\n\n")
println(a)
println("\n\n\n\n\n\n\n\n\n\n\n\n\n*************/")
}), Duration.Inf)
来源:https://stackoverflow.com/questions/50516061/scala-slick-mtable-gettables-return-empty-vector-list