db

package module
v0.0.0-...-f6467f5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2019 License: Apache-2.0 Imports: 9 Imported by: 1

README

db_util

golang implement database operation util

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseConnection

func CloseConnection(conn *sql.DB) (err error)

CloseConnection 关闭数据库连接

func GetMySQLConnInfo

func GetMySQLConnInfo(conn *sql.DB) (connInfo string, err error)

GetMySQLConnInfo 获取MySQL连接的字符串显示

func GetMySQLConnInfoIgnoreErr

func GetMySQLConnInfoIgnoreErr(conn *sql.DB) (connInfo string)

GetMySQLConnInfoIgnoreErr 获取MySQL连接的字符串显示,忽略错误信息

Types

type CheckPair

type CheckPair struct {
	Host
	UserErp string `json:"erp"`
	DBName  string `json:"dbname"`
}

CheckPair CheckPair

func (*CheckPair) String

func (cp *CheckPair) String() string

type Field

type Field struct {
	Name string
	Type string
}

Field 字段

func (*Field) FieldType

func (f *Field) FieldType() string

FieldType Common type include "STRING", "FLOAT", "INT", "BOOL"

type Host

type Host struct {
	IP     string `json:"ip"`
	Domain string `json:"domain"`
	Port   int    `json:"port"`
}

Host 主机

type MysqlDB

type MysqlDB struct {
	Host
	UserName       string
	Passwd         string
	DatabaseType   string
	DBName         string
	ConnectTimeout int
	QueryTimeout   int
}

MysqlDB Mysql主机实例

func NewMysqlDB

func NewMysqlDB() (md *MysqlDB)

NewMysqlDB 创建MySQL数据库

func NewMysqlDBWithAllParam

func NewMysqlDBWithAllParam(
	ip string, port int, userName, passwd, dbName string) (
	pmd *MysqlDB)

NewMysqlDBWithAllParam 带参数创建MySQL数据库

func (*MysqlDB) QueryRow

func (md *MysqlDB) QueryRow(stmt string) (row *QueryRow, err error)

QueryRow 执行MySQL Query语句,返回1条或0条数据

func (*MysqlDB) QueryRows

func (md *MysqlDB) QueryRows(querySQL string) (queryRows *QueryRows, err error)

QueryRows 执行MySQL Query语句,返回多条数据

type PooledMysqlDB

type PooledMysqlDB struct {
	MysqlDB
	// contains filtered or unexported fields
}

PooledMysqlDB Mysql主机实例

func NewPooledMysqlDB

func NewPooledMysqlDB() (pmd *PooledMysqlDB)

NewPooledMysqlDB 创建MySQL数据库

func NewPooledMysqlDBWithAllParam

func NewPooledMysqlDBWithAllParam(
	ip string, port int, userName, passwd, dbName string) (
	pmd *PooledMysqlDB)

NewPooledMysqlDBWithAllParam 带参数创建MySQL数据库

func NewPooledMysqlDBWithParam

func NewPooledMysqlDBWithParam(
	ip string, port int, userName, passwd string) (
	pmd *PooledMysqlDB)

NewPooledMysqlDBWithParam 带参数创建MySQL数据库

func (*PooledMysqlDB) CloseConnection

func (pmd *PooledMysqlDB) CloseConnection() (err error)

CloseConnection 获取数据库连接

func (*PooledMysqlDB) GetConnection

func (pmd *PooledMysqlDB) GetConnection() (conn *sql.DB, err error)

GetConnection 获取数据库连接

func (*PooledMysqlDB) QueryRow

func (pmd *PooledMysqlDB) QueryRow(stmt string) (row *QueryRow, err error)

QueryRow 执行MySQL Query语句

func (*PooledMysqlDB) QueryRows

func (pmd *PooledMysqlDB) QueryRows(stmt string) (queryRows *QueryRows, err error)

QueryRows 执行MySQL Query语句

type QueryRow

type QueryRow struct {
	Fields []Field
	Record map[string]interface{}
}

QueryRow 查询单行数据

type QueryRows

type QueryRows struct {
	Fields  []Field
	Records []map[string]interface{}
}

QueryRows 查询多行数据

type Scanner

type Scanner interface {
	Scan(*sql.Rows, ...*string) error
}

Scanner SQL rows读取器

func NewShowNullScanner

func NewShowNullScanner() (s Scanner)

NewShowNullScanner 显示NULL值的接收器,要求Scan的时候传入的参数是string类型

type UnanimityHost

type UnanimityHost struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

UnanimityHost id标示的主机

func (*UnanimityHost) String

func (uh *UnanimityHost) String() string

type UnanimityHostWithDomains

type UnanimityHostWithDomains struct {
	UnanimityHost
	IP      string   `json:"ip"`
	Domains []string `json:"domains"`
}

UnanimityHostWithDomains 带域名的id标示的主机

Jump to

Keyboard shortcuts

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