gorm-pool

command module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

package main

import (
	"fmt"

	"github.com/jericho-yu/gorm-pool/gormPool"
)

func main() {
	var e error
	//  创建mysql连接池
	mysqlPool := gormPool.NewMySqlPool(gormPool.NewDbSetting("./settings/db.yaml"))

	// 获取mysql链接
	mysqlConn := mysqlPool.GetConn()
	fmt.Println("mysqlConn:", mysqlConn)

	// 创建postgres链接池
	postgresPool := gormPool.NewPostgresPool(gormPool.NewDbSetting("./settings/db.yaml"))

	// 获取postgres链接
	postgresConn := postgresPool.GetConn()
	fmt.Println("postgresConn:", postgresConn)

	// 关闭数据库链接
	defer func() {
		e = mysqlPool.Close()
		if e != nil {
			panic(e)
		}
		e = postgresPool.Close()
		if e != nil {
			panic(e)
		}
	}()
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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