datasrc

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConnectTimeout is the timeout for connecting database.
	ConnectTimeout = time.Second * 5

	// QueryTimeout is the timeout for querying database.
	QueryTimeout = time.Second * 5
)

Functions

This section is empty.

Types

type ExtColumnType

type ExtColumnType struct {
	sql.ColumnType
	// contains filtered or unexported fields
}

ExtColumnType extends sql.ColumnType with some type information returned from wire but not exported.

See:

func ExtractExtColumnTypes

func ExtractExtColumnTypes(rows *sql.Rows) ([]*ExtColumnType, error)

ExtractExtColumnTypes extracts ExtColumnType(s) from sql.Rows.

func (*ExtColumnType) DataType

func (ect *ExtColumnType) DataType() string

DataType is a 'translated' column type identifier (ignore nullability). Used in scan type mapping. Available data types:

  • bool
  • int8/uint8/int16/uint16/int32/uint32/int64/uint64
  • float32/float64
  • time
  • decimal
  • bit
  • json
  • string

It returns "" for unknown type.

func (*ExtColumnType) Nullable

func (ect *ExtColumnType) Nullable() bool

Nullable returns true if the column is nullable.

func (*ExtColumnType) RawFlags

func (ect *ExtColumnType) RawFlags() uint16

RawFlags returns the raw flags.

func (*ExtColumnType) RawLength

func (ect *ExtColumnType) RawLength() uint32

RawLength returns the raw length.

func (*ExtColumnType) RawType

func (ect *ExtColumnType) RawType() uint8

RawType returns the raw type code. See: https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnType

func (*ExtColumnType) Unsigned

func (ect *ExtColumnType) Unsigned() bool

Unsigned returns true if the column is unsigned.

type Loader

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

Loader is used to load information from a MySQL database.

func NewLoader

func NewLoader(dsn string) (*Loader, error)

NewLoader creates a loader.

func (*Loader) Close

func (loader *Loader) Close()

Close release resources.

func (*Loader) Conn

func (loader *Loader) Conn() *sql.Conn

Conn returns the connection object. This connection object is also used by methods of Loader.

func (*Loader) DSN

func (loader *Loader) DSN() string

DSN returns the data source name.

func (*Loader) LoadAutoIncColumn

func (loader *Loader) LoadAutoIncColumn(tableName string) (string, error)

LoadAutoIncColumn returns the auto_increment column name of the named table or "" if not exists.

func (*Loader) LoadColumns

func (loader *Loader) LoadColumns(query string, args ...interface{}) ([]*ExtColumnType, error)

LoadColumns loads result columns of a query.

func (*Loader) LoadDBName

func (loader *Loader) LoadDBName() (string, error)

LoadDBName returns current database name.

func (*Loader) LoadFK

func (loader *Loader) LoadFK(tableName, fkName string) (columnNames []string, refTableName string, refColumnNames []string, err error)

LoadFK returns the named foreign key information.

func (*Loader) LoadFKNames

func (loader *Loader) LoadFKNames(tableName string) ([]string, error)

LoadFKNames returns all foreign key names of the named table.

func (*Loader) LoadIndex

func (loader *Loader) LoadIndex(tableName, indexName string) (columnNames []string, isPrimary bool, isUnique bool, err error)

LoadIndex loads the named index information.

func (*Loader) LoadIndexNames

func (loader *Loader) LoadIndexNames(tableName string) ([]string, error)

LoadIndexNames returns all index names of the named table.

func (*Loader) LoadTableColumns

func (loader *Loader) LoadTableColumns(tableName string) ([]*ExtColumnType, []bool, error)

LoadTableColumns returns all columns of the named table.

func (*Loader) LoadTableNames

func (loader *Loader) LoadTableNames() ([]string, error)

LoadTableNames returns all normal table names in current database.

Jump to

Keyboard shortcuts

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