mysqldump

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

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 14 Imported by: 0

README

export-mysql

导出mysql数据库到sql文件备份数据库

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug          bool      // 是否调试模式
	IsExportData   bool      // 是否导出数据
	ExportDataStep int64     // 导出数据时,每次查询数据量
	IsCreateDB     bool      // 是否生成建库语句
	OutPath        string    // 输出sql文件目录-绝对路径-用于导出
	SQLPath        string    // 导入的sql文件-绝对路径-用于导入
	OutZip         bool      // 是否导出zip压缩文件
	DbCfg          *DbConfig // 数据库连接信息
}

Config 导出sql所需的配置信息

type CreateDb

type CreateDb struct {
	Database       string `xorm:"'Database'"`
	CreateDatabase string `xorm:"'Create Database'"`
}

CreateDb 创建数据库 sql查询

type CreateTable

type CreateTable struct {
	Table       string `xorm:"'Table'"`
	CreateTable string `xorm:"'Create Table'"`
}

CreateTable 创建table sql查询

type DbConfig

type DbConfig struct {
	Address string // 数据库连接地址
	Port    int    // 数据库端口
	User    string // 数据库用户名
	Passwd  string // 数据库密码
	DbName  string // 数据库名
}

DbConfig 数据库连接配置

type Mysqldump

type Mysqldump struct {
	// contains filtered or unexported fields
}

Mysqldump mysql导出数据对象

func New

func New(cfg *Config) (*Mysqldump, error)

New 创建一个Mysqldump对象

func (*Mysqldump) Close

func (md *Mysqldump) Close() error

Close 不使用导出功能时,关闭连接资源

func (*Mysqldump) Export

func (md *Mysqldump) Export() (outFile string, err error)

Export 导出数据库所有表

func (*Mysqldump) ExportData

func (md *Mysqldump) ExportData(w io.Writer, tableName string) (err error)

ExportData 导出数据为

func (*Mysqldump) GetCreateDbSQL

func (md *Mysqldump) GetCreateDbSQL() (string, error)

GetCreateDbSQL 获取创建数据库

func (*Mysqldump) GetCreateTableSQL

func (md *Mysqldump) GetCreateTableSQL(tableName string) (string, error)

GetCreateTableSQL 查询创建表语句

func (*Mysqldump) GetRootDir

func (md *Mysqldump) GetRootDir() string

GetRootDir 获取程序跟目录,返回值尾部包含'/'

func (*Mysqldump) Import

func (md *Mysqldump) Import(sqlPath ...string) (err error)

Import 导入sql文件到数据库

func (*Mysqldump) OpenMysql

func (md *Mysqldump) OpenMysql() error

OpenMysql 连接mysql

func (*Mysqldump) SelectTableNames

func (md *Mysqldump) SelectTableNames() (tables []string, err error)

SelectTableNames 查询数据库表列表

type TPLModel

type TPLModel struct {
	MySQL *DbConfig
	SQL   []*TPLSqlModel
	Date  string
}

TPLModel 导出数据结构体

type TPLSqlModel

type TPLSqlModel struct {
	TableName string // 表名
	CreateSQL string // 创建表sql语句
	InsertSQL string // 插入数据sql语句
}

TPLSqlModel 导出数据sql部分

type TableColumn

type TableColumn interface {
}

TableColumn 用于读取数据库每一列数据

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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