doufei2194 2015-09-30 14:39
浏览 140
已采纳

如何使用gocql执行cql文件?

If you were to interface directly with Cassandra using cqlsh you could do the following:

$ cqlsh
cqlsh:test> SOURCE '/home/me/reset_db.cql'

I've tried to do this using gocql several times but I always get an error. For example, running this:

filePath := "/home/me/reset_db.cql"
SOURCE_FILE := "SOURCE (?)"
resetErr := session.Query(SOURCE_FILE, filePath).Exec()

Produces the following error:

line 1:0 no viable alternative at input 'SOURCE' ([SOURCE]...)

So what am I doing wrong here?

  • 写回答

1条回答 默认 最新

  • dtnbjjq51949 2015-10-02 05:20
    关注

    SOURCE is a shortcut in cqlsh, not valid CQL command in general.

    You'll need to read the file contents into strings and execute them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖