sqldriver

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 19 Imported by: 1

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

}
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 Array added in v0.1.2

type Array data.Array

func (Array) IsNull added in v0.1.2

func (n Array) IsNull() bool

func (*Array) Scan added in v0.1.2

func (n *Array) Scan(value interface{}) error

func (Array) String added in v0.1.2

func (n Array) String() string

type Binary added in v0.1.2

type Binary sql.RawBytes

func (Binary) IsNull added in v0.1.2

func (n Binary) IsNull() bool

func (*Binary) Scan added in v0.1.2

func (n *Binary) Scan(value interface{}) error

func (Binary) String added in v0.1.2

func (n Binary) String() string

type Config

type Config = odps.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.

func ParseDSN

func ParseDSN(dsn string) (*Config, error)

ParseDSN dsn格式如下 http://AccessId:AccessKey@host:port/path?project=<project_name>&stsToken=<sts_token>&tcpConnectionTimeout=30&httpTimeout=60&tunnelQuotaName=<quota_name> 其中project参数为必填项

type Decimal added in v0.1.2

type Decimal data.Decimal

func (Decimal) IsNull added in v0.1.2

func (n Decimal) IsNull() bool

func (*Decimal) Scan added in v0.1.2

func (n *Decimal) Scan(value interface{}) error

func (Decimal) String added in v0.1.2

func (n Decimal) String() string

type Map added in v0.1.2

type Map data.Map

func (Map) IsNull added in v0.1.2

func (n Map) IsNull() bool

func (*Map) Scan added in v0.1.2

func (n *Map) Scan(value interface{}) error

func (Map) String added in v0.1.2

func (n Map) String() string

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 NullAble added in v0.1.2

type NullAble interface {
	IsNull() bool
}

type NullBool added in v0.1.2

type NullBool sql.NullBool

func (NullBool) IsNull added in v0.1.2

func (n NullBool) IsNull() bool

func (*NullBool) Scan added in v0.1.2

func (n *NullBool) Scan(value interface{}) error

type NullDate added in v0.1.2

type NullDate sql.NullTime

func (NullDate) IsNull added in v0.1.2

func (n NullDate) IsNull() bool

func (*NullDate) Scan added in v0.1.2

func (n *NullDate) Scan(value interface{}) error

func (NullDate) String added in v0.1.2

func (n NullDate) String() string

type NullDateTime added in v0.1.2

type NullDateTime sql.NullTime

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

type NullFloat32 struct {
	Float32 float32
	Valid   bool
}

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 NullInt16 added in v0.1.2

type NullInt16 struct {
	Int16 int16
	Valid bool //Valid is true if Int16 is not NULL
}

func (NullInt16) IsNull added in v0.1.2

func (n NullInt16) IsNull() bool

func (*NullInt16) Scan added in v0.1.2

func (n *NullInt16) Scan(value interface{}) error

type NullInt32 added in v0.1.2

type NullInt32 sql.NullInt32

func (NullInt32) IsNull added in v0.1.2

func (n NullInt32) IsNull() bool

func (*NullInt32) Scan added in v0.1.2

func (n *NullInt32) Scan(value interface{}) error

type NullInt64 added in v0.1.2

type NullInt64 sql.NullInt64

func (NullInt64) IsNull added in v0.1.2

func (n NullInt64) IsNull() bool

func (*NullInt64) Scan added in v0.1.2

func (n *NullInt64) Scan(value interface{}) error

type NullInt8 added in v0.1.2

type NullInt8 struct {
	Int8  int8
	Valid bool //Valid is true if Int16 is not NULL
}

func (NullInt8) IsNull added in v0.1.2

func (n NullInt8) IsNull() bool

func (*NullInt8) Scan added in v0.1.2

func (n *NullInt8) 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

type NullTimeStamp sql.NullTime

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{}

func (OdpsDriver) Open

func (d OdpsDriver) Open(name string) (driver.Conn, error)

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{})

type Struct added in v0.1.2

type Struct data.Struct

func (Struct) IsNull added in v0.1.2

func (n Struct) IsNull() bool

func (*Struct) Scan added in v0.1.2

func (n *Struct) Scan(value interface{}) error

func (Struct) String added in v0.1.2

func (n Struct) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL