New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

github.com/godoes/gorm-dameng

Package Overview
Dependencies
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/godoes/gorm-dameng

Source
Go Modules
Version
v0.7.2
Version published
Created
Source

GORM DM8 Driver

基于达梦数据库官方 Go 驱动源码 二次开发整理的开箱即用的 GORM 达梦数据库驱动,无需单独复制驱动源码到项目中。 获取达梦最新官方 Go 驱动请访问 https://eco.dameng.com/download/

最低要求

快速上手

安装

go get -d github.com/godoes/gorm-dameng

用例

package main

import (
	"encoding/json"
	"fmt"

	"github.com/godoes/gorm-dameng"
	"gorm.io/gorm"
)

func main() {
	options := map[string]string{
		"schema":         "SYSDBA",
		"appName":        "GORM 连接达梦数据库示例",
		"connectTimeout": "30000",
	}

	// dm://user:password@host:port?schema=SYSDBA[&...]
	dsn := dameng.BuildUrl("user", "password", "127.0.0.1", 5236, options)
	// VARCHAR 类型大小为字符长度
	//db, err := gorm.Open(dameng.New(dameng.Config{DSN: dsn, VarcharSizeIsCharLength: true}))
	// VARCHAR 类型大小为字节长度(默认)
	db, err := gorm.Open(dameng.Open(dsn), &gorm.Config{})
	if err != nil {
		// panic error or log error info
	}

	// do somethings
	var versionInfo []map[string]interface{}
	db.Table("SYS.V$VERSION").Find(&versionInfo)
	if err := db.Error; err == nil {
		versionBytes, _ := json.MarshalIndent(versionInfo, "", "  ")
		fmt.Printf("达梦数据库版本信息:\n%s\n", versionBytes)
	}
}

/****************** 控制台输出内容 *****************

达梦数据库版本信息:
[
  {
    "BANNER": "DM Database Server 64 V8"
  },
  {
    "BANNER": "DB Version: 0x7000c"
  },
  {
    "BANNER": "03134284094-20230927-******-*****"
  }
]

*************************************************/

参考文档

达梦技术文档

GORM 文档

FAQs

Package last updated on 22 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts