driver

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMultipleQueries = NewError("unsupported multi queries")
	ErrQuery           = NewError("unsupported query")
	ErrNilPtr          = NewError("destination pointer is nil")
)

Error messages.

Functions

func NewError

func NewError(text string) error

NewDriverError returns an error of type Driver with the given text.

func NewXError

func NewXError(text string, arg interface{}) error

NewDriverError returns an error of type Driver with the given text.

Types

type AdvancedDriver

type AdvancedDriver struct{}

Driver implements all methods to pretend as a sql database driver. It is an advanced version of Awql driver. It adds cache, the possibility to get database details.

func (*AdvancedDriver) Open

func (d *AdvancedDriver) Open(dsn string) (driver.Conn, error)

Open returns a new connection to the database. @see DatabaseDir:CacheDir:WithCache|AdwordsId[:ApiVersion:SupportsZeroImpressions]|DeveloperToken[|ClientId][|ClientSecret][|RefreshToken] @example /data/base/dir:/cache/dir:false|123-456-7890:v201607:true|dEve1op3er7okeN|1234567890-c1i3n7iD.com|c1ien753cr37|1/R3Fr35h-70k3n

type AutoNullFloat64

type AutoNullFloat64 struct {
	NullFloat64 sql.NullFloat64
	Auto        bool
}

AutoNullFloat64 represents a float64 that may be null or defined as auto valuer.

func (AutoNullFloat64) Value

func (n AutoNullFloat64) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type AutoNullInt64

type AutoNullInt64 struct {
	NullInt64 sql.NullInt64
	Auto      bool
}

AutoNullInt64 represents a int64 that may be null or defined as auto valuer.

func (AutoNullInt64) Value

func (n AutoNullInt64) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn represents a connection to a database and implements driver.Conn.

func (*Conn) Begin

func (c *Conn) Begin() (driver.Tx, error)

Begin is dedicated to start a transaction and awql does not support it.

func (*Conn) Close

func (c *Conn) Close() error

Close marks this connection as no longer in use.

func (*Conn) Prepare

func (c *Conn) Prepare(q string) (driver.Stmt, error)

Prepare returns a prepared statement, bound to this connection.

type CreateViewStmt

type CreateViewStmt struct {
	*Stmt
}

CreateViewStmt represents a Create statement.

func (*CreateViewStmt) Exec

func (s *CreateViewStmt) Exec() (driver.Result, error)

Query executes a Create View query.

type DescribeStmt

type DescribeStmt struct {
	*Stmt
}

DescribeStmt represents a Describe statement.

func (*DescribeStmt) Query

func (s *DescribeStmt) Query() (driver.Rows, error)

Query executes a Describe query, such as a DESC or DESCRIBE. It returns the properties of a table, filtered if requested on one field.

type Dsn

type Dsn struct {
	DatabaseDir,
	CacheDir,
	Src string
	WithCache bool
}

Dsn represents a data source name.

func NewDsn

func NewDsn(db, src, cache string, cached bool) *Dsn

NewDsn returns a new instance of Dsn.

func (*Dsn) String

func (d *Dsn) String() (s string)

String outputs the data source name as string. /data/base/dir:/cache/dir:false|123-456-7890:v201607|dEve1op3er7okeN|1234567890-c1i3n7iD.com|c1ien753cr37|1/R3Fr35h-70k3n

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents a internal error.

func (*Error) Error

func (e *Error) Error() string

Error outputs a query error message.

type Execer

type Execer interface {
	Exec() (driver.Result, error)
}

Execer is an interface that may be implemented by a CreateViewStmt.

func NewCreateViewStmt

func NewCreateViewStmt(stmt *Stmt) Execer

NewCreateViewStmt returns an instance of CreateViewStmt. It implements Queryer interface.

type Float64

type Float64 struct {
	Float64   float64
	Precision int
}

Float64Int represents a float64 that may be rounded by using its precision.

func (Float64) Value

func (n Float64) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullString

type NullString struct {
	String string
	Valid  bool // Valid is true if String is not NULL
}

NullString represents a string that may be null.

func (NullString) Value

func (n NullString) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Queryer

type Queryer interface {
	Query() (driver.Rows, error)
}

Queryer is an interface that should be implemented by a Stmt with rows as result.

func NewDescribeStmt

func NewDescribeStmt(stmt *Stmt) Queryer

NewDescribeStmt returns an instance of DescribeStmt. It implements Queryer interface.

func NewSelectStmt

func NewSelectStmt(stmt *Stmt) Queryer

NewSelectStmt returns an instance of SelectStmt. It implements Queryer interface.

func NewShowStmt

func NewShowStmt(stmt *Stmt) Queryer

NewShowStmt returns an instance of ShowStmt. It implements Queryer interface.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result is the result of a query execution.

func (*Result) LastInsertId

func (r *Result) LastInsertId() (int64, error)

LastInsertId returns the database's auto-generated ID after, for example, an INSERT into a table with primary key.

func (*Result) RowsAffected

func (r *Result) RowsAffected() (int64, error)

RowsAffected returns the number of rows affected by the query.

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

Rows is an iterator over an executed query's results. It implements sort and driver.Rows interfaces.

func (*Rows) Close

func (r *Rows) Close() error

Close closes the rows iterator.

func (*Rows) Columns

func (r *Rows) Columns() []string

Columns returns the names of the columns.

func (*Rows) Len

func (r *Rows) Len() int

Len

func (*Rows) Less

func (r *Rows) Less(i, j int) bool

Less

func (*Rows) Limit

func (r *Rows) Limit(offset, rowCount int)

Limit bounds the slice of rows.

func (*Rows) Next

func (r *Rows) Next(dest []driver.Value) error

Next is called to populate the next row of data into the provided slice.

func (*Rows) Sort

func (r *Rows) Sort()

Sort sorts rows as expected by less functions.

func (*Rows) Swap

func (r *Rows) Swap(i, j int)

Swap

type SelectStmt

type SelectStmt struct {
	*Stmt
}

SelectStmt represents a Select statement.

func (*SelectStmt) Hash

func (s *SelectStmt) Hash() string

Hash builds a unique hash for this query and this Adwords ID.

func (*SelectStmt) Query

func (s *SelectStmt) Query() (driver.Rows, error)

Query executes a SELECT query It internally calls the Awql driver, aggregates, sorts and limits the results.

type ShowStmt

type ShowStmt struct {
	*Stmt
}

ShowStmt represents a Show statement.

func (*ShowStmt) Query

func (s *ShowStmt) Query() (driver.Rows, error)

Query executes a SHOW query It returns a list of a table, filtered if requested with the like or with clause.

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

Stmt is a prepared statement.

func (*Stmt) Bind

func (s *Stmt) Bind(args []driver.Value) error

Bind applies the required argument replacements on the query.

func (*Stmt) Close

func (s *Stmt) Close() error

Close closes the statement.

func (*Stmt) Exec

func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)

Exec executes a query that doesn't return rows, such as an INSERT or UPDATE.

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

NumInput returns the number of placeholder parameters.

func (*Stmt) Query

func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)

Query sends request to Google Adwords API and retrieves its content.

type Time

type Time struct {
	Time   time.Time
	Layout string
}

NullTime represents a Time that may be not set.

func (Time) Value

func (n Time) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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