package test

import (
	"fmt"
	"testing"
)

func TestDBQuery(t *testing.T) {
	rows, err := db.Query("select * from gotab2;")
	if err != nil {
		fmt.Printf("[ERROR] %s\n", err.Error())
		return
	}

	column, err := rows.Columns()
	if err != nil {
		fmt.Printf("[ERROR] %s\n", err.Error())
		return
	}
	rows_value := make([]interface{}, len(column))
	for key, _ := range rows_value {
		dest := make([]byte, 216)
		rows_value[key] = &dest
	}

	for rows.Next() {
		rows.Scan(rows_value...)

		for _, v := range rows_value {
			fmt.Printf("结果: %s\t", string(*(v.(*[]byte))))
		}
		fmt.Printf("\n")
	}

	rows.Close()
	db.Close()
}
