mysqlparser

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MysqlType2GoType = map[string]string{
	"int":       "int64",
	"tinyint":   "uint8",
	"bigint":    "int64",
	"varchar":   "string",
	"char":      "string",
	"text":      "string",
	"date":      "time.Time",
	"time":      "time.Time",
	"datetime":  "time.Time",
	"timestamp": "time.Time",
	"json":      "string",
}

Functions

func GenerateFile

func GenerateFile(ddl string) error

func GetDDLs

func GetDDLs() ([]string, error)

func GetTables

func GetTables() []string

func Run

func Run() error

Types

type Field

type Field struct {
	IsPK               bool   `json:"is_pk"`
	Name               string `json:"name"`
	UpperCamelCaseName string `json:"upper_camel_case_name"`
	Type               string `json:"type"`
	Comment            string `json:"comment"`
	DefaultValue       string `json:"default_value"`
	Tag                string `json:"tag"`
}

type Table

type Table struct {
	Name               string  `sql:"name"`
	UpperCamelCaseName string  `sql:"upper_camel_case_name"`
	Comment            string  `sql:"comment"`
	Fields             []Field `sql:"fields"`
	ContainsTimeField  bool    `sql:"contains_time"`
}

func ParseMysqlDDL

func ParseMysqlDDL(s string) (Table, error)

func (*Table) GenerateCode

func (t *Table) GenerateCode() string

Jump to

Keyboard shortcuts

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