|
|
13 年之前 | |
|---|---|---|
| uuid | 13 年之前 | |
| AUTHORS | 13 年之前 | |
| LICENSE | 13 年之前 | |
| README.md | 13 年之前 | |
| convert.go | 13 年之前 | |
| gocql.go | 13 年之前 | |
| gocql_test.go | 13 年之前 |
The gocql package provides a database/sql driver for CQL, the Cassandra query language.
This package requires a recent version of Cassandra (≥ 1.2) that supports CQL 3.0 and the new native protocol. The native protocol is still considered beta and must be enabled manually in Cassandra 1.2 by setting "start_native_transport" to true in conf/cassandra.yaml.
go get github.com/tux21b/gocql
db, err := sql.Open("gocql", "localhost:8000 keyspace=system")
// ...
rows, err := db.Query("SELECT keyspace_name FROM schema_keyspaces")
// ...
for rows.Next() {
var keyspace string
err = rows.Scan(&keyspace)
// ...
fmt.Println(keyspace)
}
if err := rows.Err(); err != nil {
// ...
}
Please see gocql_test.go for some more advanced examples.
database/sql packageCopyright (c) 2012 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.