database

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 21 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Discard = New(log.New(ioutil.Discard, "", log.LstdFlags), config{})
	Default = New(log.New(os.Stdout, "\r\n", log.LstdFlags), config{
		SlowThreshold: 200 * time.Millisecond,
		LogLevel:      logger.Warn,
		Colorful:      true,
	})
	Recorder = traceRecorder{Interface: Default, BeginAt: time.Now()}
)
View Source
var CONFIG = Mysql{
	Path:         "127.0.0.1:3306",
	Config:       "charset=utf8mb4&parseTime=True&loc=Local",
	DbName:       "iris-admin",
	Username:     "root",
	Password:     "",
	MaxIdleConns: 0,
	MaxOpenConns: 0,
	LogMode:      false,
	LogZap:       "error",
}
View Source
var ErrDatabaseInit = errors.New("database initialize fail")

Functions

func DorpDB

func DorpDB(dsn, driver, dbName string) error

func Init added in v1.1.2

func Init() error

Init initialize mysql config file

func Instance

func Instance() *gorm.DB

Instance

func IsExist

func IsExist() bool

IsExist config file is exist

func New

func New(writer writer, config config) logger.Interface

New

func Recover added in v1.2.0

func Recover() error

Recover

func Remove

func Remove() error

Remove remove config file

Types

type Mysql

type Mysql struct {
	Path         string `mapstructure:"path" json:"path" yaml:"path"`
	Config       string `mapstructure:"config" json:"config" yaml:"config"`
	DbName       string `mapstructure:"db-name" json:"db-name" yaml:"db-name"`
	Username     string `mapstructure:"username" json:"username" yaml:"username"`
	Password     string `mapstructure:"password" json:"password" yaml:"password"`
	MaxIdleConns int    `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"`
	MaxOpenConns int    `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"`
	LogMode      bool   `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"`
	LogZap       string `mapstructure:"log-zap" json:"log-zap" yaml:"log-zap"` //silent,error,warn,info,zap
}

func (*Mysql) BaseDsn

func (m *Mysql) BaseDsn() string

Dsn return

func (*Mysql) Dsn

func (m *Mysql) Dsn() string

Dsn return mysql dsn

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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