Documentation ¶
Index ¶
- Variables
- type ExtColumnType
- type Loader
- func (loader *Loader) Close()
- func (loader *Loader) Conn() *sql.Conn
- func (loader *Loader) DSN() string
- func (loader *Loader) LoadAutoIncColumn(tableName string) (string, error)
- func (loader *Loader) LoadColumns(query string, args ...interface{}) ([]*ExtColumnType, error)
- func (loader *Loader) LoadDBName() (string, error)
- func (loader *Loader) LoadFK(tableName, fkName string) (columnNames []string, refTableName string, refColumnNames []string, err error)
- func (loader *Loader) LoadFKNames(tableName string) ([]string, error)
- func (loader *Loader) LoadIndex(tableName, indexName string) (columnNames []string, isPrimary bool, isUnique bool, err error)
- func (loader *Loader) LoadIndexNames(tableName string) ([]string, error)
- func (loader *Loader) LoadTableColumns(tableName string) ([]*ExtColumnType, []bool, error)
- func (loader *Loader) LoadTableNames() ([]string, error)
Constants ¶
This section is empty.
Variables ¶
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.
- ColumnType.Length is not supported yet (https://github.com/go-sql-driver/mysql/pull/667).
- 'unsigned' or not can't be known if type ColumnType.ScanType returns NullInt64.
See:
- https://github.com/go-sql-driver/mysql/blob/master/fields.go mysqlField
- https://github.com/go-sql-driver/mysql/blob/master/packets.go mysqlConn.readColumns
- https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::ColumnDefinition41
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 (*Loader) Conn ¶
Conn returns the connection object. This connection object is also used by methods of Loader.
func (*Loader) LoadAutoIncColumn ¶
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 ¶
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 ¶
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 ¶
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 ¶
LoadTableNames returns all normal table names in current database.