mysql2struct

package
v0.0.0-...-91e2a0d Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBTypeToStructType = map[string]string{
	"int":        "int32",
	"tinyint":    "int8",
	"smallint":   "int",
	"mediumint":  "int64",
	"bigint":     "int64",
	"bit":        "int",
	"bool":       "bool",
	"enum":       "string",
	"set":        "string",
	"varchar":    "string",
	"char":       "string",
	"tinytext":   "string",
	"mediumtext": "string",
	"text":       "string",
	"longtext":   "string",
	"blob":       "string",
	"tinyblob":   "string",
	"mediumblob": "string",
	"longblob":   "string",
	"date":       "time.Time",
	"datetime":   "time.Time",
	"timestamp":  "time.Time",
	"time":       "time.Time",
	"float":      "float64",
	"double":     "float64",
}

Functions

This section is empty.

Types

type DBInfo

type DBInfo struct {
	DBType   string
	Host     string
	UserName string
	Password string
	Charset  string
}

type DBModel

type DBModel struct {
	DBEngine *sql.DB
	DBInfo   *DBInfo
}

func NewDBModel

func NewDBModel(info *DBInfo) *DBModel

func (*DBModel) Connect

func (m *DBModel) Connect() error

func (*DBModel) GetColumns

func (m *DBModel) GetColumns(dbName string, tableName string) ([]*TableColumn, error)

type StructColumn

type StructColumn struct {
	Name    string
	Type    string
	Tag     string
	Comment string
}

type StructTemplate

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

func NewStructTemplate

func NewStructTemplate() *StructTemplate

func (*StructTemplate) AssemblyColumns

func (t *StructTemplate) AssemblyColumns(tbColumns []*TableColumn) []*StructColumn

func (*StructTemplate) Generate

func (t *StructTemplate) Generate(tableName string, tplColumns []*StructColumn) error

type StructTemplateDB

type StructTemplateDB struct {
	TableName string
	Columns   []*StructColumn
}

type TableColumn

type TableColumn struct {
	ColumnName    string
	DataType      string
	IsNullable    string
	ColumnKey     string
	ColumnType    string
	ColumnComment string
}

Jump to

Keyboard shortcuts

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