tplsql

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxLimit  = 10000                                                  // Max read rows limit
	FieldName = rows.MakeFieldName("sql")                              // Field name
	MaxFork   = 3                                                      // Max fork
	Template  = template.New("tplsql")                                 // template
	Stdout    = os.Stdout                                              // std out
	Log       = log.New(Stdout, "[grm] ", log.LstdFlags|log.Llongfile) // Print
	Println   = func(i ...interface{}) {
		Log.Output(3, fmt.Sprint(i...))
	} // logger
	GetDB = func() (*sql.DB, error) {
		db, err := grm.Get()
		return db, err
	} // db conn
)

Functions

func Gen

func Gen(conn string, out string) error

func GetDataType2GoType

func GetDataType2GoType(dt string) string

Types

type DefinesTplData

type DefinesTplData struct {
	Type      string
	Comm      string
	Name      string
	Sql       string
	Parameter []*ParameterTplData
}

func MakeDeleteFirst

func MakeDeleteFirst(table string, col []*RespGetColumn) *DefinesTplData

func MakeInsertInfo

func MakeInsertInfo(table string, col []*RespGetColumn) *DefinesTplData

func MakeSelectAll

func MakeSelectAll(table string, col []*RespGetColumn) *DefinesTplData

func MakeSelectFirst

func MakeSelectFirst(table string, col []*RespGetColumn) *DefinesTplData

func MakeUpdateFirst

func MakeUpdateFirst(table string, col []*RespGetColumn) *DefinesTplData

type ParameterTplData

type ParameterTplData struct {
	Method    string
	Name      string
	OriAsName string
	OriName   string
	Type      string
	Tags      string
	Comm      string
}

type ReqGetColumn

type ReqGetColumn struct {
	TableSchema string `sql:"table_schema"` // 数据库名
	TableName   string `sql:"table_name"`   // 表名
}

type ReqGetCreateTable

type ReqGetCreateTable struct {
	TableSchema string `sql:"table_schema"` // 数据库名
	TableName   string `sql:"table_name"`   // 表名
}

type ReqGetTable

type ReqGetTable struct {
	TableSchema string `sql:"table_schema"` // 数据库名
}

type ReqGetTableCount

type ReqGetTableCount struct {
	TableSchema string `sql:"table_schema"` // 数据库名
}

type RespGetColumn

type RespGetColumn struct {
	TableCatalog           string `sql:"table_catalog"`            // 表目录
	TableSchema            string `sql:"table_schema"`             // 数据库名
	TableName              string `sql:"table_name"`               // 表名
	ColumnName             string `sql:"column_name"`              // 字段名
	OrdinalPosition        int    `sql:"ordinal_position"`         // 字段所在位置
	ColumnDefault          string `sql:"column_default"`           // 字段默认值
	IsNullable             string `sql:"is_nullable"`              // 能是空值
	DataType               string `sql:"data_type"`                // 数据类型
	CharacterMaximumLength int    `sql:"character_maximum_length"` // 字符串最大长度
	CharacterOctetLength   int    `sql:"character_octet_length"`   // 字符串位长度
	NumericPrecision       int    `sql:"numeric_precision"`        // 数字精度
	NumericScale           string `sql:"numeric_scale"`            // 数字比例
	DatetimePrecision      int    `sql:"datetime_precision"`       // 时间精度
	CharacterSetName       string `sql:"character_set_name"`       // 字符编码
	CollationName          string `sql:"collation_name"`           // 字符编码
	ColumnType             string `sql:"column_type"`              // 列类型
	ColumnKey              string `sql:"column_key"`               // 列键
	Extra                  string `sql:"extra"`                    // 额外属性
	Privileges             string `sql:"privileges"`               // 特供
	ColumnComment          string `sql:"column_comment"`           // 注释
}

func GetColumn

func GetColumn(req *ReqGetColumn, dbs ...grm.DBQuery) (resp []*RespGetColumn, err error)

type RespGetCreateTable

type RespGetCreateTable struct {
	SqlCreateTable string `sql:"sql_create_table"` // 创建表的sql
}

func GetCreateTable

func GetCreateTable(req *ReqGetCreateTable, dbs ...grm.DBQuery) (resp *RespGetCreateTable, err error)

type RespGetSchema

type RespGetSchema struct {
	TableSchema string `sql:"table_schema"` // 获取 当前数据库名
}

func GetSchema

func GetSchema(dbs ...grm.DBQuery) (resp *RespGetSchema, err error)

type RespGetTable

type RespGetTable struct {
	TableName string `sql:"table_name"` // 所有表
}

func GetTable

func GetTable(req *ReqGetTable, dbs ...grm.DBQuery) (resp []*RespGetTable, err error)

type RespGetTableCount

type RespGetTableCount struct {
	Count int `sql:"count"`
}

func GetTableCount

func GetTableCount(req *ReqGetTableCount, dbs ...grm.DBQuery) (resp *RespGetTableCount, err error)

Jump to

Keyboard shortcuts

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