一、建立连接
GORM 官方支持的数据库类型有: MySQL, PostgreSQL, SQlite, SQL Server
package mysql
import (
"fmt"
"testing..."
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
type config struct {
user...parseTime=True&loc=Local", conf.user, conf.pass, conf.adrr, conf.port, conf.dbname)
db, err := gorm.Open("mysql...这是方式一,下面来写方式二
package mysql
import (
"fmt"
"testing"
"time"
"gorm.io/driver/mysql"
"gorm.io/gorm...parseTime=True&loc=Local", conf.user, conf.pass, conf.adrr, conf.port, conf.dbname)
db, err := gorm.Open(mysql.Open