GoFrame

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 4 Imported by: 0

README

GoFrame

Parse GoFrame DB config to GORM DSN

Go Reference

Support Database:

  • SQLite
  • Oracle
  • PostgreSQL
  • MySQL
  • MicrosoftSQL
  • Clickhouse

Example:

package main

import (
	"fmt"

	"gitlab.com/z2a-package/Go/Gorm/GoFrame"
	"gitlab.com/z2a-package/Go/Gorm/GoFrame/PostgreSQL"
	"github.com/gogf/gf/v2/database/gdb"
	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

func main() {
	config := &gdb.ConfigNode{
		Host: "127.0.0.1",
		Port: "5432",
		User: "postgres",
		Pass: "",
		Name: "postgres",
	}

	config = GoFrame.ParseConfigNode(config)
	source := PostgreSQL.ParseDataSourceName(config)
	dialector := postgres.Open(source)
	_, throw := gorm.Open(dialector)

	if nil != throw {
		fmt.Println("open database fail")
	} else {
		fmt.Println("open database success")
	}

}



Documentation

Index

Constants

View Source
const (
	DefaultCharset  = `utf8`
	DefaultProtocol = `tcp`
	LinkPattern     = `(\w+):([\w\-]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)`
)

Variables

This section is empty.

Functions

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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