簡體   English   中英

如何使用phantom for Scala在Cassandra中創建表?

[英]How do you create a table in Cassandra using phantom for Scala?

我正在嘗試在https://github.com/websudos/phantom/blob/develop/phantom-example/src/main/scala/com/websudos/phantom/example/basics/SimpleRecipes.scala上運行示例創建了一個配方並嘗試使用insertNewRecord(myRecipe)插入它,並得到以下異常: ....InvalidQueryException: unconfigured columnfamily my_custom_table 我使用cqlsh進行了檢查,並創建了鍵空間,但沒有創建表。

所以我的問題是,如何使用幻像創建表? 在任何示例代碼中都沒有提到這一點,我也無法通過幻像源代碼來弄清楚。

您需要使用架構自動生成來創建表。 只需執行:

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM