tableparser

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constraint

type Constraint struct {
	ConstraintName        string
	ColumnName            string
	ReferencedTableSchema string
	ReferencedTableName   string
	ReferencedColumnName  string
}

Constraint holds Foreign Keys information

type Field

type Field struct {
	TableCatalog           string
	TableSchema            string
	TableName              string
	ColumnName             string
	OrdinalPosition        int
	ColumnDefault          sql.NullString
	IsNullable             bool
	DataType               string
	CharacterMaximumLength sql.NullInt64
	CharacterOctetLength   sql.NullInt64
	NumericPrecision       sql.NullInt64
	NumericScale           sql.NullInt64
	DatetimePrecision      sql.NullInt64
	CharacterSetName       sql.NullString
	CollationName          sql.NullString
	ColumnType             string
	ColumnKey              string
	Extra                  string
	Privileges             string
	ColumnComment          string
	GenerationExpression   string
	SetEnumVals            []string
	Constraint             *Constraint
	SrsID                  sql.NullString
}

Field holds raw field information as defined in INFORMATION_SCHEMA

type Index

type Index struct {
	Name       string
	Fields     []string
	Unique     bool
	Visible    bool
	Expression string // MySQL 8.0.16+
}

Index holds the basic index information

type IndexField

type IndexField struct {
	KeyName      string
	SeqInIndex   int
	ColumnName   string
	Collation    sql.NullString
	Cardinality  sql.NullInt64
	SubPart      sql.NullInt64
	Packed       sql.NullString
	Null         string
	IndexType    string
	Comment      string
	IndexComment string
	NonUnique    bool
	Visible      string         // MySQL 8.0+
	Expression   sql.NullString // MySQL 8.0.16+
}

IndexField holds raw index information as defined in INFORMATION_SCHEMA table

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Table

type Table struct {
	Schema  string
	Name    string
	Fields  []Field
	Indexes map[string]Index
	//TODO Include complete indexes information
	Constraints []Constraint
	Triggers    []Trigger
	// contains filtered or unexported fields
}

Table holds the table definition with all fields, indexes and triggers

func NewTable

func NewTable(db *sql.DB, schema, tableName string) (*Table, error)

func (*Table) FieldNames

func (t *Table) FieldNames() []string

FieldNames returns an string array with the table's field names

type Trigger

type Trigger struct {
	Trigger             string
	Event               string
	Table               string
	Statement           string
	Timing              string
	Created             NullTime
	SQLMode             string
	Definer             string
	CharacterSetClient  string
	CollationConnection string
	DatabaseCollation   string
}

Trigger holds raw trigger information as defined in INFORMATION_SCHEMA

Jump to

Keyboard shortcuts

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