dao

package
v3.2.10 Latest Latest
Warning

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

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

README

import (
	"time"

	"github.com/abulo/ratel/v3/gen/mysql2struct"
	"github.com/abulo/ratel/v3/store/mysql"
	"github.com/abulo/ratel/v3/util"
)

var MySQL *mysql.ProxyPool = mysql.NewProxyPool()

func main() {
	opt := &mysql.Config{}
	opt.Username = "root"
	opt.Password = "mysql"
	opt.Host = "127.0.0.1"
	opt.Port = "3306"
	opt.Charset = "utf8mb4"
	opt.Database = "xmt"
	opt.DriverName = "mysql"
	opt.MaxLifetime = time.Duration(1) * time.Minute
	opt.MaxIdleTime = time.Duration(1) * time.Minute
	opt.MaxIdleConns = util.ToInt(64)
	opt.MaxOpenConns = util.ToInt(64)

	conn := mysql.New(opt)

	mysql2struct.MysqlToStruct(conn, "xmt", "sss", "dddd")
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DataTypeMap = map[string][]string{

	"TINYINT":   {"int64", "query.NullInt64"},
	"SMALLINT":  {"int64", "query.NullInt64"},
	"MEDIUMINT": {"int64", "query.NullInt64"},
	"INT":       {"int64", "query.NullInt64"},
	"INTEGER":   {"int64", "query.NullInt64"},
	"BIGINT":    {"int64", "query.NullInt64"},

	"FLOAT":   {"float64", "query.NullFloat64"},
	"DOUBLE":  {"float64", "query.NullFloat64"},
	"DECIMAL": {"float64", "query.NullFloat64"},

	"DATE":      {"query.NullDate", "query.NullDate"},
	"TIME":      {"query.NullTime", "query.NullTime"},
	"YEAR":      {"query.NullYear", "query.NullYear"},
	"DATETIME":  {"query.NullDateTime", "query.NullDateTime"},
	"TIMESTAMP": {"query.NullTime", "query.NullTime"},

	"CHAR":       {"string", "query.NullString"},
	"VARCHAR":    {"string", "query.NullString"},
	"TINYBLOB":   {"string", "query.NullString"},
	"TINYTEXT":   {"string", "query.NullString"},
	"BLOB":       {"string", "query.NullString"},
	"TEXT":       {"string", "query.NullString"},
	"MEDIUMBLOB": {"string", "query.NullString"},
	"MEDIUMTEXT": {"string", "query.NullString"},
	"LONGBLOB":   {"string", "query.NullString"},
	"LONGTEXT":   {"string", "query.NullString"},
	"JSON":       {"string", "query.NullString"},
}

DataTypeMap ...

Functions

func CamelStr

func CamelStr(name string) string

CamelStr 下划线转驼峰

func Run

func Run(db *query.Query, DbName, outputDir, outputPackage string)

Run ...

 db		sql链接
 DbName  数据库名称
	outputDir: "输出目录",
	outputPackage: "struct文件的包名

Types

type Column

type Column struct {
	ColumnName    string `db:"COLUMN_NAME"`
	IsNullable    string `db:"IS_NULLABLE"`
	DataType      string `db:"DATA_TYPE"`
	ColumnKey     string `db:"COLUMN_KEY"`
	ColumnComment string `db:"COLUMN_COMMENT"`
}

Column ...

type Config

type Config struct {
	// Username      string `json:"username"`
	// Password      string `json:"password"`
	// Protocol      string `json:"protocol"`
	// Address       string `json:"address"`
	// Dbname        string `json:"dbname"`
	// TableName     string `json:"tableName"`
	OutputDir     string `json:"outputDir"`
	OutputPackage string `json:"outputPackage"`
}

Config ...

type Table

type Table struct {
	TableName    string `db:"TABLE_NAME"`
	TableComment string `db:"TABLE_COMMENT"`
}

Table ...

Jump to

Keyboard shortcuts

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