Documentation
¶
Overview ¶
Example ¶
package main
import (
"database/sql"
account2 "github.com/aliyun/aliyun-odps-go-sdk/odps/account"
"github.com/aliyun/aliyun-odps-go-sdk/odps/restclient"
"github.com/aliyun/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)
}
}
Index ¶
- Variables
- type Array
- type Binary
- type Config
- type Decimal
- type Map
- type NamedArgQuery
- type NullAble
- type NullBool
- type NullDate
- type NullDateTime
- type NullFloat32
- type NullFloat64
- type NullInt16
- type NullInt32
- type NullInt64
- type NullInt8
- type NullString
- type NullTimeStamp
- type OdpsDriver
- type PositionArgQuery
- type Struct
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 NullDateTime ¶ added in v0.1.2
func (NullDateTime) IsNull ¶ added in v0.1.2
func (n NullDateTime) IsNull() bool
func (*NullDateTime) Scan ¶ added in v0.1.2
func (n *NullDateTime) Scan(value interface{}) error
func (NullDateTime) String ¶ added in v0.1.2
func (n NullDateTime) String() string
type NullFloat32 ¶ added in v0.1.2
func (NullFloat32) IsNull ¶ added in v0.1.2
func (n NullFloat32) IsNull() bool
func (*NullFloat32) Scan ¶ added in v0.1.2
func (n *NullFloat32) Scan(value interface{}) error
type NullFloat64 ¶ added in v0.1.2
type NullFloat64 sql.NullFloat64
func (NullFloat64) IsNull ¶ added in v0.1.2
func (n NullFloat64) IsNull() bool
func (*NullFloat64) Scan ¶ added in v0.1.2
func (n *NullFloat64) Scan(value interface{}) error
type NullString ¶ added in v0.1.2
type NullString sql.NullString
func (NullString) IsNull ¶ added in v0.1.2
func (n NullString) IsNull() bool
func (*NullString) Scan ¶ added in v0.1.2
func (n *NullString) Scan(value interface{}) error
type NullTimeStamp ¶ added in v0.1.2
func (NullTimeStamp) IsNull ¶ added in v0.1.2
func (n NullTimeStamp) IsNull() bool
func (*NullTimeStamp) Scan ¶ added in v0.1.2
func (n *NullTimeStamp) Scan(value interface{}) error
func (NullTimeStamp) String ¶ added in v0.1.2
func (n NullTimeStamp) String() string
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.