mysql

package
v0.7.24 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, dsn string, logger log.Logger, opts ...Option) (*gorm.DB, error)

Types

type Option

type Option func(*Options)

func WithConnMaxIdleTime

func WithConnMaxIdleTime(t time.Duration) Option

func WithConnMaxLifetime

func WithConnMaxLifetime(t time.Duration) Option

func WithDryRun added in v0.7.13

func WithDryRun(b bool) Option

func WithIgnoreRecordNotFoundError added in v0.7.13

func WithIgnoreRecordNotFoundError(b bool) Option

func WithMaxIdleConns

func WithMaxIdleConns(n int) Option

func WithMaxOpenConns

func WithMaxOpenConns(n int) Option

func WithParameterizedQueries added in v0.7.13

func WithParameterizedQueries(b bool) Option

func WithSlowThreshold added in v0.7.13

func WithSlowThreshold(t time.Duration) Option

type Options

type Options struct {
	MaxIdleConns              int           // 最大空闲连接数
	MaxOpenConns              int           // 最大打开连接数
	ConnMaxLifetime           time.Duration // 连接重用最大时间
	ConnMaxIdleTime           time.Duration // 连接空闲最大时间
	SlowThreshold             time.Duration // TraceLog打印慢查询日志时的阈值
	IgnoreRecordNotFoundError bool          // TraceLog打印错误日志时是否忽略RecordNotFound错误
	ParameterizedQueries      bool          // TraceLog打印日志时SQL语句是否使用?占位符代替实际的参数
	DryRun                    bool          // 生成SQL但不执行
}

Jump to

Keyboard shortcuts

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