Create SQL INSERT statement from YAML file.
Suits for fixture data.
$ go get github.com/evalphobia/go-yml2sql
$ go-yml2sql -y <yaml file>
INSERT INTO `foo`(`col1`, `col2`) VALUES('1', 'a'), ('2', 'b'), ('3', 'c');-y: yaml file path.-t: table naming type.fileis from file name,diris from dir name of the file. (default=dir)-plural: flag for making table name pluralize or not. (default=true)
import(
"github.com/evalphobia/go-yml2sql/yml2sql"
)
func main(
path := "/path/to/bank/fixture.yml"
yml2sql.SetPlural(true)
yml2sql.SetNamingTypeDir(true)
stmt := yml2sql.CreateStatementByFile(path)
// execute insert `banks` table
_, err := db.Exec(stmt)
if err != nil {
panic(err.Error())
}
)Apache License, Version 2.0