CrowdStrike/golang-driver

Name: golang-driver

Owner: Crowdstrike

Description: Golang wrapper of the DataStax/Cassandra C++ driver

Forked from: mstump/golang-driver

Created: 2015-08-31 18:19:35.0

Updated: 2016-07-07 16:02:58.0

Pushed: 2015-08-31 18:24:11.0

Homepage: null

Size: 98

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

golang-driver

Golang wrapper of the DataStax/Cassandra C/C++ driver 2.1 api

Basic support for prepared statements and ad hoc queries. Lacking support for collections, but that will be remedied shortly.

Build
  1. Build and install the DataStax C/C++ driver 2.1 api
  2. Install go get github.com/mstump/golang-driver/cassandra
  3. Run the example go run $GOPATH/src/github.com/mstump/golang-driver/examples/basic.go
Example Usage
age main

rt (
"fmt"
"golang-driver/cassandra"


 main() {
cluster := cassandra.NewCluster()
cluster.SetContactPoints("cassandra")
defer cluster.Finalize()

session := cassandra.NewSession()
defer session.Finalize()

sessfuture := cluster.SessionConnect(session)
sessfuture.Wait()
defer sessfuture.Finalize()

statement := cassandra.NewStatement("select cluster_name from system.local;", 0)
defer statement.Finalize()

stmtfuture := session.Execute(statement)
stmtfuture.Wait()
defer stmtfuture.Finalize()

result := stmtfuture.Result()
defer result.Finalize()

fmt.Printf("Clusters:\r\n")
for result.Next() {
    var clusterName string
    result.Scan(&clusterName)
    fmt.Printf("%s\n", clusterName)
}

fmt.Printf("DONE.\r\n")


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.