I created a keyspace in eu-west-3.
When I try with the same query in cqlsh it works but with golang doesn't. Someone can help me?
cluster := gocql.NewCluster("cassandra.eu-west-3.amazonaws.com:9142")
cluster.ConnectTimeout = time.Second * 10
var auth sigv4.AwsAuthenticator = sigv4.NewAwsAuthenticator()
auth.Region = "eu-west-3"
auth.AccessKeyId = "ex"
auth.SecretAccessKey = "ex"
cluster.Authenticator = auth
cluster.SslOpts = &gocql.SslOptions{
CaPath: "./sf-class2-root.crt",
EnableHostVerification: false,
}
cluster.Consistency = gocql.LocalQuorum
cluster.DisableInitialHostLookup = true
session, err := cluster.CreateSession()
if err != nil {
fmt.Println("err>", err)
return
}
session.Query("INSERT INTO ex.accounts (id, username, email) VALUES (uuid(),'user1','[email protected]' ) ;")
A quick glance over your code shows that your query contains a semi-colon (
;) at the end. It should just be:However, I don't know if that's the problem because you haven't provided sufficient detail in your question.
The general guidance is that you (a) provide a good summary of the problem that includes software/component versions, the full error message + full stack trace; (b) describe what you've tried to fix the problem, details of investigation you've done; and (c) minimal sample code that replicates the problem. Cheers!