Skip to content

jasonlabz/gorm-dm-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gorm-dm-driver

达梦数据库 gorm方言包

使用方法同gorm官方支持的mysql、postgres等一致

go get

go get github.com/jasonlabz/gorm-dm-driver@master

DSN格式:

dm://user:password@host:port?schema=SYSDBA[&propName2=propValue2]…

具体用法示例

可参考: 代码示例: https://github.com/jasonlabz/dbutil/blob/master/dbx/db.go

package main

import (
	"gorm.io/gorm"
	dm "github.com/jasonlabz/gorm-dm-driver"
)

func main() {
	dialect := dm.Open("dm://user:password@host:port?schema=SYSDBA[&propName2=propValue2]…")

	db, err := gorm.Open(dialect)
	if err != nil {
		return err
	}

	sqlDB, err := db.DB()
	if err != nil {
		return err
	}
	//sqlDB.SetMaxOpenConns(config.MaxOpenConn)
	//sqlDB.SetMaxIdleConns(config.MaxIdleConn)
	//sqlDB.SetConnMaxLifetime(config.ConnMaxLifeTime)
	//dbWrapper := &DBWrapper{
	//	DB:     db,
	//	Config: config,
	//}
	//dbMap.Store(config.DBName, dbWrapper)
	//return nil
}

About

取自达梦官方源码 支持GORM driver.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages