sql2struct

package
v0.0.0-...-61261bc Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, 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