Documentation ¶
Overview ¶
Example ¶
package main import ( "database/sql" account2 "github.com/jiuzhiqian/aliyun-odps-go-sdk/odps/account" "github.com/jiuzhiqian/aliyun-odps-go-sdk/odps/restclient" "github.com/jiuzhiqian/aliyun-odps-go-sdk/sqldriver" "log" ) func main() { var account = account2.AliyunAccountFromEnv() var endpoint = restclient.LoadEndpointFromEnv() config := sqldriver.NewConfig() config.Endpoint = endpoint config.AccessId = account.AccessId() config.AccessKey = account.AccessKey() config.ProjectName = "project_1" dsn := config.FormatDsn() db, err := sql.Open("odps", dsn) if err != nil { log.Fatalf("%+v", err) } rows, err := db.Query("select ti, si, i, bi, b, f, d from data_type_demo;", nil) if err != nil { log.Fatalf("%+v", err) } var ti int8 var si int16 var i int32 var bi int64 var b []byte var f float32 var d float64 for rows.Next() { err = rows.Scan(&ti, &si, &i, &bi, &b, &f, &d) if err != nil { log.Fatalf("%+v", err) } println(ti, si, i, bi, b, f, d) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NewConfig = odps.NewConfig
View Source
var NewConfigFromIni = odps.NewConfigFromIni
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config is a configuration parsed from a DSN string. If a new Config is created instead of being parsed from a DSN string, the NewConfig function should be used, which sets default values.
type NamedArgQuery ¶
type NamedArgQuery struct {
// contains filtered or unexported fields
}
func NewNamedArgQuery ¶
func NewNamedArgQuery(query string) NamedArgQuery
func (*NamedArgQuery) SetArg ¶
func (n *NamedArgQuery) SetArg(name string, value interface{})
type OdpsDriver ¶
type OdpsDriver struct{}
type PositionArgQuery ¶
type PositionArgQuery struct {
// contains filtered or unexported fields
}
func NewPositionArgQuery ¶
func NewPositionArgQuery(query string) PositionArgQuery
func (*PositionArgQuery) SetArgs ¶
func (p *PositionArgQuery) SetArgs(args ...interface{})
Click to show internal directories.
Click to hide internal directories.