0

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?

4

1 回答 1

2

SOURCE是 cqlsh 中的快捷方式,通常不是有效的 CQL 命令。

您需要将文件内容读入字符串并执行它们。

于 2015-10-02T05:20:13.487 回答