Giter Site home page Giter Site logo

golang-driver's Introduction

golang-driver

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

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. 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

package main

import (
	"fmt"
	"golang-driver/cassandra"
)

func 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")
}

golang-driver's People

Contributors

dinedal avatar mstump avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

golang-driver's Issues

Idiomatic Go

I noticed that there is heavy use of "Cass" in function names like NewCassCluster or NewCassStatement. Is there another cluster or statement type other than those for Cassandra in this package? If not, I think the more idiomatic way of doing this is to remove Cass from the function names. My 2 cents..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.