mysql

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mysql 提供 MySQL 数据库驱动接入。

本包为可选驱动: 业务项目仅当 import 本包时才会拉取 gorm.io/driver/mysql 及其依赖, 未使用的驱动(postgres/sqlite 等)不会进入业务项目的依赖树。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQL

type MySQL struct {
	database.DatabasePool // 数据库连接池配置

	LoggerLevel string `yaml:"logger_level" toml:"logger_level" json:"logger_level" mapstructure:"logger_level"` // 日志级别: silent, warn, warning, info, error
	Host        string `yaml:"host" toml:"host" json:"host" mapstructure:"host"`                                 // 数据库主机
	Port        int    `yaml:"port" toml:"port" json:"port" mapstructure:"port"`                                 // 数据库端口
	User        string `yaml:"user" toml:"user" json:"user" mapstructure:"user"`                                 // 数据库用户名
	Password    string `yaml:"password" toml:"password" json:"password" mapstructure:"password"`                 // 数据库密码
	DB          string `yaml:"db" toml:"db" json:"db" mapstructure:"db"`                                         // 数据库名称
	Charset     string `yaml:"charset" toml:"charset" json:"charset" mapstructure:"charset"`                     // 数据库字符集: utf8mb4
}

MySQL 数据库配置

func (*MySQL) Connect

func (m *MySQL) Connect() error

Connect 连接数据库

func (*MySQL) DSN

func (m *MySQL) DSN() string

DSN 数据库连接字符串

Jump to

Keyboard shortcuts

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