Skip to content
/ gohive Public
forked from kharism/gohive

A hive client with SASL support in Go, only support branch 0.10.0 of apache thrift

Notifications You must be signed in to change notification settings

wdxtub/gohive

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoHive

A hive client with SASL support based on thrift.

Usage

package main

import (
	"fmt"
	"github.com/lwldcr/gohive"
	"github.com/lwldcr/gohive/tcliservice"
	"os"
)

func main() {
	// first build a new transport
	// of course we can wrap all these routine operations into functions for repeatedly using
	// replace HIVE_HOST, PORT, HIVE_USER, HIVE_PASSWD with your own configurations
	t, err := gohive.NewTSaslTransport(HIVE_HOST, PORT, HIVE_USER, HIVE_PASSWD, gohive.DefaultOptions)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
    
	// now open it
	if err := t.Open(); err != nil {
    	fmt.Println(err)
    	os.Exit(1)
    }
    defer t.Close()
    
    // execute query
    rows, err := t.Query("SHOW TABLES")
    if err != nil {
    	fmt.Println(err)
    	os.Exit(1)
    }
    defer rows.Close()
    
    // check status
    status, err := rows.Wait()
    if !status.IsSuccess() {
    	fmt.Println("unsuccessful query", status)
    	os.Exit(1)
    }
    
    var (
    	tableName string
    )
    
    // scan results
    for rows.Next() {
    	rows.Scan(&tableName)
    	fmt.Println("tablename:", tableName)
    }
}

About

A hive client with SASL support in Go, only support branch 0.10.0 of apache thrift

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%