sql

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FILEPATH = "mysql_config.yaml"

Variables

This section is empty.

Functions

func Connect

func Connect(c *Config, dataSourceName string) (*sql.DB, error)

func FormatConfig

func FormatConfig(c *BaseConfig) string

Types

type BaseConfig

type BaseConfig struct {
	UserName,
	PassWord,
	Addr,
	Port,
	DBName string
}

Configuration file structure

func InitReadConfig

func InitReadConfig(KeyName, FilePath string) BaseConfig

type Config

type Config struct {
	DSN          string        // write data source name.
	ReadDSN      string        // read data source name.
	Active       int           // pool
	Idle         int           // pool
	IdleTimeout  time.Duration // connect max life time.
	QueryTimeout time.Duration // query sql timeout
	ExecTimeout  time.Duration // execute sql timeout
	TranTimeout  time.Duration // transaction sql timeout
}

type DB

type DB struct {
	Write  *conn
	Read   *conn
	Idx    int64
	Master *DB
}

func ConnectMysql

func ConnectMysql(WriteKey, ReadKey, FilePath string) (db *DB)

func Open

func Open(c *Config) (*DB, error)

func OpenMySQL

func OpenMySQL(c *Config) (db *DB)

func (*DB) Close

func (db *DB) Close() (err error)

type Rows

type Rows struct {
	*Rows
	// contains filtered or unexported fields
}

Rows rows.

Jump to

Keyboard shortcuts

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