问题
I am trying to run the example on https://github.com/websudos/phantom/blob/develop/phantom-example/src/main/scala/com/websudos/phantom/example/basics/SimpleRecipes.scala
,So I created a Recipe and tried to insert it using insertNewRecord(myRecipe)
and got the following exception: ....InvalidQueryException: unconfigured columnfamily my_custom_table
.
I checked using cqlsh and the keyspace was created but the table was not.
So my question is, how do I create the table using phantom? This is never mentioned in any of the example code and I also could not figure it out by going over the phantom source code.
回答1:
You need to create the table using schema autogeneration. Simply execute:
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import com.websudos.phantom.dsl._
// To execute this, you need an implicit keySpace and a session.
Await.ready(SimpleRecipes.create.ifNotExists().future(), 3.seconds)
来源:https://stackoverflow.com/questions/31124834/how-do-you-create-a-table-in-cassandra-using-phantom-for-scala