MySQL
Package mysql providers MySQL database driver.
Installation
go get -u github.com/gopi-frame/database/mysql
Import
import _ "github.com/gopi-frame/database/mysql"
Usage
package main
import (
"github.com/gopi-frame/database"
_ "github.com/gopi-frame/database/mysql"
)
func main() {
db, err := database.Connect("mysql", map[string]any{
"dsn": "user:password@tcp(127.0.0.1:3306)/database?parseTime=true",
})
if err!= nil {
panic(err)
}
}
Options
This package uses package mapstructure to parse options.
For more information on the options, see mysql.Config.
Example
var options = map[string]any{
"dsn": "user:password@tcp(127.0.0.1:3306)/database?parseTime=true",
"SkipInitializeWithVersion": true,
"DefaultStringSize": 255,
}