| commit | d0d29fe034d600c0a98a7ebd06cddd5a81089d6f | [log] [tgz] |
|---|---|---|
| author | Phillip Couto <phillip@couto.in> | Mon Jul 14 21:15:38 2014 -0400 |
| committer | Phillip Couto <phillip@couto.in> | Mon Jul 14 21:15:38 2014 -0400 |
| tree | efad1db58156360e1b1a99bb4dc02ccdf0de577c | |
| parent | 20ba163d1ee6e2123dcf311a774c499ca3624fa1 [diff] |
Added skip statements for tests that use batch api when the protocol version is 1.
Package Status: Alpha
Package gocql implements a fast and robust Cassandra client for the Go programming language.
Project Website: http://gocql.github.io/
API documentation: http://godoc.org/github.com/gocql/gocql
Discussions: https://groups.google.com/forum/#!forum/gocql
go get github.com/gocql/gocql
Marshaler and Unmarshaler interfacePlease visit the Roadmap page to see what is on the horizion.
gocql no longer supports executing “use ” statements to simplfy the library. The user still has the ability to define the default keyspace for connections but now the keyspace can only be defined before a session is created. Queries can still access keyspaces by indicating the keyspace in the query:
SELECT * FROM example2.table;
Example of correct usage:
cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3")
cluster.Keyspace = "example"
...
session, err := cluster.CreateSession()
Example of incorrect usage:
cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3")
cluster.Keyspace = "example"
...
session, err := cluster.CreateSession()
if err = session.Query("use example2").Exec(); err != nil {
log.Fatal(err)
}
This will result in an err being returned from the session.Query line as the user is trying to execute a “use” statement.
package main import ( "fmt" "log" "github.com/gocql/gocql" ) func main() { // connect to the cluster cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3") cluster.Keyspace = "example" cluster.Consistency = gocql.Quorum session, _ := cluster.CreateSession() defer session.Close() // insert a tweet if err := session.Query(`INSERT INTO tweet (timeline, id, text) VALUES (?, ?, ?)`, "me", gocql.TimeUUID(), "hello world").Exec(); err != nil { log.Fatal(err) } var id gocql.UUID var text string // select a single tweet if err := session.Query(`SELECT id, text FROM tweet WHERE timeline = ? LIMIT 1`, "me").Consistency(gocql.One).Scan(&id, &text); err != nil { log.Fatal(err) } fmt.Println("Tweet:", id, text) // list all tweets iter := session.Query(`SELECT id, text FROM tweet WHERE timeline = ?`, "me").Iter() for iter.Scan(&id, &text) { fmt.Println("Tweet:", id, text) } if err := iter.Close(); err != nil { log.Fatal(err) } }
Copyright (c) 2012-2014 The gocql Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.