mysql

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDatabaseIfNotExists

func CreateDatabaseIfNotExists(driverName, dataSourceName, databaseName string, ops ...Option) error

CreateDatabaseIfNotExists If database not exists, then create it.

func GormComment

func GormComment(description string) string

GormComment get table comment for the description.

func NewConnection

func NewConnection(config *Config, ops ...Option) (*gorm.DB, error)

NewConnection create a new gorm db instance with the given options.

func NewDataSourceName

func NewDataSourceName(host, username, password, database string, ops ...Option) string

NewDataSourceName initialize database of the data source name. If database parameter is empty, will not choose database, such as only open database connection.

func NewDataSourceNameForConfig

func NewDataSourceNameForConfig(config *Config, ops ...Option) string

NewDataSourceNameForConfig Get data source name for given options.

func NewDataSourceNameForNoSelectDatabase

func NewDataSourceNameForNoSelectDatabase(host, username, password string, ops ...Option) string

Types

type Config

type Config struct {
	Host                  string
	Username              string
	Password              string
	Database              string
	MaxIdleConnections    int
	MaxOpenConnections    int
	MaxConnectionLifeTime time.Duration
	LogLevel              int
	Logger                logger.Interface
	DriverName            connecter.DriverName
}

Config defines config for database.

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithCharset

func WithCharset(charset string) Option

func WithLocation

func WithLocation(loc string) Option

func WithParseTime

func WithParseTime(parseTime bool) Option

Jump to

Keyboard shortcuts

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